apache - 301 Redirect For Folder Not Working -
i have issues 301 redirect. not rules working. noticed particularly, rules redirect folder 1 not working.
these among rules generated cpanel:
rewritecond %{http_host} ^domain\.org$ [or] rewritecond %{http_host} ^www\.domain\.org$ rewriterule ^index\.html$ "http\:\/\/www\.domain\.org\/" [r=301,l] rewritecond %{http_host} ^domain\.org$ [or] rewritecond %{http_host} ^www\.domain\.org$ rewriterule ^subfolder\/$ "http\:\/\/www\.domain\.org\/" [r=301,l]
the first 1 says redirect domain.org/index.html
domain.org/
, works fine. second 1 meant redirect domain.org/subfolder/
domain.org
not.
can 301 redirect can redirect access folder?
once remove quotes , escape characters target in rewriterule should work fine.
rewritecond %{http_host} ^domain\.org$ [or] rewritecond %{http_host} ^www\.domain\.org$ rewriterule ^index\.html$ http://www.domain.org/ [r=301,l] rewritecond %{http_host} ^domain\.org$ [or] rewritecond %{http_host} ^www\.domain\.org$ rewriterule ^subfolder/$ http://www.domain.org/ [r=301,l]
subfolder literal word "subfolder" if you're trying redirect non-existent subfolders, might try below. \w
same [a-za-z0-9_]
, we're allowing hyphens.
rewritecond %{http_host} ^domain\.org$ [or] rewritecond %{http_host} ^www\.domain\.org$ rewriterule ^([\w-]+)/?$ http://www.domain.org/ [r=301,l]
Comments
Post a Comment