1

I am writing a simple .htaccess- file to limit the access to my site.
Now, that this site is ok, I'd like to rewrite the url, but it seems that my regexs have no effect..

Here is my .htaccess - file:

AuthType Basic
AuthUserFile /www/MW_qXXGGqXqq/mysite.it/.htpasswd
AuthName "Members Area"
require valid-user
RewriteEngine on
RewriteBase /
DirectoryIndex index.php

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^https?://(?:www\.)?mysite.it(?:$|/) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule \.(gif|jpg|jpeg|png|mp3|mpg|avi|mov)$ - [F,NC]

RewriteRule ^[management]$ yacht_management.php [NC,L]
RewriteRule ^[yacht]$ list_yacht.php [NC,L]
RewriteRule ^[technicalsupport]$ technical_support.php [NC,L]
RewriteRule ^[crew]$ inquiry.php [NC,L]
RewriteRule ^[contact]$ contact.php [NC,L]

How can I change this code so my url becomes www.mysite.it/management/ instead of www.mysite.it/yacht_management.php?

low_rents
  • 4,481
  • 3
  • 27
  • 55
P.Davide
  • 377
  • 2
  • 6
  • 19

1 Answers1

0

You are using a [character class] here:

RewriteRule ^[management]$ yacht_management.php [NC,L]

That will not match the whole word, but just one of the letters from it.

Leave out the square brackets:

RewriteRule ^management$ yacht_management.php [NC,L]

Then also include the trailing / slash that you want, preferrably make it optional with ?:

RewriteRule ^management/?$ yacht_management.php [NC,L]

Same for all your other rules.

mario
  • 144,265
  • 20
  • 237
  • 291
  • See also [Open source RegexBuddy alternatives](http://stackoverflow.com/questions/89718/is-there) and [Online regex testing](http://stackoverflow.com/questions/32282/regex-testing) for some helpful tools, or [RegExp.info](http://regular-expressions.info/) for a nicer tutorial. – mario Feb 16 '14 at 21:31
  • I tried but it seems to do not affect the url.. it remains the same.. I'd like, for example, that an url become like: www.easyyacht.ch/yacht_management.php to www.easyyacht.ch/managment I don't know why it doesnt' work.. – P.Davide Feb 18 '14 at 18:13
  • `mod_rewrite` is for incoming URLs, not patching outgoing. Rewrite the in-HTML links yourself. – mario Feb 18 '14 at 18:16
  • Ok, please, give more information about it.. what I have to look for? and, so, to better understand what you said, what are incoming url? like, for example, a url coming from a database request? – P.Davide Feb 18 '14 at 18:34