Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need help with redirecting using pattern matching and htacces

Status
Not open for further replies.

robintel

Technical User
Mar 30, 2009
1
Hi, I need to redirect pages like:

example.com/[<b>something wrong</b>]/index.php/[something else]/article.html

The idea is that if there is [<b>something wrong</b>] before the /index.php/ part, other than the website URL then the 301 should occur. Sorry for the bold, I need to emphasize that if there is some string before the /index.php/ part of the SEF URL then the 301 should occur.

The URLs are like this:

example.com/<two|three directories:remove all>/index.php/<two other drectories:keep all>/<title_of_the_article.html:keep>

This is way beyond my .htaccess skill...

Thank you!
 
If you can use mod_rewrite, one of the following may work for you. If you would send examples of the URLs that should reidrect/not redirect, that would help.

The patterns below should redirect URLs that have something inserted before /index.php example: /something/index.php

The RewriteCond directive may not be necessary, but is a check that we are NOT redirecting /index.php

The only difference between the two rules below is that the leading / is dropped for the pattern matching in .htaccess

1.
# inside httpd.conf - I have tested this version
RewriteEgine on
RewriteCond %{REQUEST_URI} !^/index\.php$
RewriteRule ^/.*/index\.php$ [R=301,L]

OR

2.
# inside .htaccess - I haven't tested this one
RewriteEgine on
RewriteCond %{REQUEST_URI} !^index\.php$
RewriteRule ^.*/index\.php$ [R=301,L]

Rob

Rob Jordan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top