The reason why is that I have no content at the root domain and would like to simply redirect users to the blog.
Seems rather simple, yet so far I’ve had no luck. And any .htaccess example I can find never attempts to achieve this setup. Generally it’s the opposite: from a subdirectory to the root directory, but never from the root directory to a subdirectory.
The “trick” to this question was that mod_rewrite is not the proper way to solve the problem.
As for your code, it’s good that you made the attempt (appreciated by all, I’m sure) but it would result in a loop (because of the inappropriate use of the :kaioken: EVERYTHING :kaioken: atom)! Whenever you use that, you MUST provide an escape from the loop. In this case, a RewriteCond testing the {REQUEST_URI} against ^blog/ would have been in order.
I’m NOT sure what your second RewriteRule was supposed to do except endlessly prepend blog/ to … er … blog/? The same RewriteCond could be used here, too.
As a “teacher” in this forum, I MUST correct code so that you (and other members who look at your code) understand the problem and know where/how to fix the loops! I hope this helped your understanding.
I was searching the Internet for such a question!
The trouble (in my case) is that I have no access to vhost to use DocumentRoot, so htaccess is (I think) my answer. Anyway, in order to solve this problem with htaccess I’m trying the followin code (without success!).
Second, this was an old thread that had been resolved (apparently). You should have started a new thread.
Third, you don’t need to have access to the httpd(-vhosts).conf file if you have access to cPanel (or another control panel) which can interface with the server for you.
As for your code where do I start?
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/blog [NC,S=1]
# Skip the next RewriteRule? :nono:
RewriteRule ^.*$ /pagenotfound.html [L]
# redirect EVERYTHING (which is not requested of /blog)? :nono:
RewriteCond %{REQUEST_URI} !^/blog [NC]
RewriteRule ^.*$ /blog/$1
# Finally, that makes sense - except for the lack of Last flag.
Perhaps a review of my signature’s mod_rewrite tutorial?
Thanks for answering (I assumed keeping things organized would be important, but I get your message on “old threads”…), and answering fast!
I’ll be checking my cPanel more carefully.
As for the code… that bad an? lol
I think I haven’t quite got the principles of the thing… Not that I haven’t done some working lines, but it seems so random…
I’ll be taking a look at your tutorial (you mean datakoncepts.com/seo, right?(no links for me, yet))