mod_rewrite for selectors with .html

Posted by user1720607 on Server Fault See other posts from Server Fault or by user1720607
Published on 2012-10-04T16:35:28Z Indexed on 2012/10/10 3:40 UTC
Read the original article Hit count: 449

Filed under:
|
|

We have a website where the URL looks something like, www.example.com/about.smart.html

( "smart" being selector added on the app server based on the useragent if its a smart phone device)

We need to redirect the page to 404 if the URL is changed by the user as like below:

  1. www.example.com/about.abc.xyz.smart.html
  2. www.example.com/about.smart.abc.html

I tried with the below rule, but this redirects to 404 only for 1) and not for 2)

RewriteCond  %{REQUEST_URI} !^(.*)(-)\.html$
RewriteRule (.*)\.(.*).smart.html$ - [R=404,L] 

Any pointers on this would be of great help.

© Server Fault or respective owner

Related posts about mod-rewrite

Related posts about apache2