Mobile app version of vmapp.org
Login or Join
Sarah324

: Is this a valid redirect-rule return http 301? I am relaunching a website with over 10'000 pages, must adapt URL a tiny bit and need to be sure my redirect-rules are correct. I simply need

@Sarah324

Posted in: #Htaccess #ModRewrite

I am relaunching a website with over 10'000 pages, must adapt URL a tiny bit and need to be sure my redirect-rules are correct.

I simply need to add a "S" before the ID of that particular URL.

So can anyone tell me if this rule is correct and returning a http 301?

RewriteCond %{REQUEST_URI} ^http://www.slople.com/italia/venetien-veneto-friaul-julisch-venetien-venezien/romagnano-azzagoverona-grezzana/pendio-monte-sviola/S1/
RewriteRule ^(.*)$ www.slople.com/italia/venetien-veneto-friaul-julisch-venetien-venezien/romagnano-azzagoverona-grezzana/pendio-monte-sviola/1/ [R=301,L]


Modified according to comment:

RewriteCond %{REQUEST_URI} ^http://www.slople.com/italia/venetien-veneto-friaul-julisch-venetien-venezien/romagnano-azzagoverona-grezzana/pendio-monte-sviola/1/
RewriteRule ^(.*)$ www.slople.com/italia/venetien-veneto-friaul-julisch-venetien-venezien/romagnano-azzagoverona-grezzana/pendio-monte-sviola/S1/ [R=301,L]


More info

To be more precise on my question, what I need is:

Redirect every URL with a numeric ID at the end (with or without trailing slash) not starting with "/activity"

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Sarah324

1 Comments

Sorted by latest first Latest Oldest Best

 

@Jamie184

Okay. There is a mod_dir httpd.apache.org/docs/2.2/mod/mod_dir.html which provides for a trailing slash redirect. You might want to enable this to make your life a lot easier. It is the module LoadModule dir_module modules/mod_dir.so in your configuration- you may need to un-comment this out. This reduces half of the work.

From there, you can add the following code in your .htaccess:

RewriteCond %{REQUEST_URI} !^/activity.*$ [NC]
RewriteRule ^(.*)/([0-9]+)/$ www.example.com//S/ [R=301,L]


This should be a clean solution for you.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme