Wednesday 15 January 2014

apache - .htaccess error hard to find ... -



apache - .htaccess error hard to find ... -

code:

<ifmodule mod_rewrite.c> # domain re-direction rewriteengine on rewritecond %{http_host} ^stackexchange\.net$ [or] rewritecond %{http_host} ^www\.stackexchange\.net$ rewriterule ^/?$ "https\:\/\/www\.stackexchange\.org\/“ [r=301] # #support page re-direction rewritecond %{request_uri} ^thesupport/?$ [nc] rewriterule ^thesupport/?$ https\:\/\/www\.stackexchange\.org\/support\/ [r=301] # #privacy page re-direction rewritecond %{request_uri} ^privacy/?$ [nc] rewriterule ^privacy/?$ https\:\/\/www\.stackexchange\.org\/privacy\/ [r=301,l] </ifmodule>

problem:

301 redirect stackexchange.net stackexchange.org working 301 redirect stackexchange.net/thesupport stackexchange.org/support not working (always gives 404 page)

no difference problem if %{request_uri} replaced either:

%{the_request} %{request_filename} %{remote_uri}

i have gone on http://code.tutsplus.com/tutorials/an-in-depth-guide-to-mod_rewrite-for-apache--net-6708 can’t seem find error coming from.

any ideas in regards might wrong hatches code.

thanks.

problem in condition:

rewritecond %{request_uri} ^thesupport/?$ [nc]

since request_uri matches uri leading slash. corrected status should be:

rewritecond %{request_uri} ^/thesupport/?$ [nc]

however looking @ rule don't need status , can handle in rewriterule itself.

<ifmodule mod_rewrite.c> # domain re-direction rewriteengine on rewritecond %{http_host} ^(www\.)?stackexchange\.net$ rewriterule ^/?$ https://www.stackexchange.org [r=301,l] # #support page re-direction rewriterule ^thesupport/?$ https://www.stackexchange.org/support/ [r=301,l] # #privacy page re-direction rewriterule ^privacy/?$ https://www.stackexchange.org/privacy/ [r=301,l] </ifmodule>

apache .htaccess mod-rewrite redirect

No comments:

Post a Comment