Jump to content

do pretty urls require a file extension?


wright67uk

Recommended Posts

In my .htaccess file I change the url that appears in my browser to one that is more memorable. 

 

 

RewriteRule ^valeting\.html$ VALETING\.php?subtype=VALETING [L,NC]

Which works well.

 

OR

 

RewriteRule ^valeting\.php$ VALETING\.php?subtype=VALETING [L,NC]

Which also works well.

 

Why is it that when I knock of the file extension such as;

 

RewriteRule ^valeting$ VALETING\.php?subtype=VALETING [L,NC]

All I get is a 404 error?

 

How can I get around this?

Link to comment
https://forums.phpfreaks.com/topic/244827-do-pretty-urls-require-a-file-extension/
Share on other sites

Thank you for the reply, my htaccess file is now as below;

 

I have a lot to learn but I realised that if I add \.* after valeting that I can miss off the extension in my browser.

www.mysite.co.uk/VALETING.php?subtype=VALETING is the actual url that exists and www.mysite.co.uk/valeting

is my now clean and fictional URL.

 

<Files ~ "^\.(htaccess|htpasswd)$">

allow from all

</Files>

 

AddHandler x-httpd-php5 .php

AddHandler x-httpd-php .php4

 

Options +Indexes +FollowSymlinks -MultiViews

 

RewriteEngine on

RewriteBase /

 

RewriteCond %{HTTP_HOST} ^(mysite\.co\.uk)(:80)? [NC]

RewriteRule ^(.*) http://www.mysite.co.uk/$1 [R=301]

 

RewriteRule ^courier\.*$ COURIER\.php?subtype=COURIER [NC,L,N]

RewriteRule ^valeting\.*$ VALETING\.php?subtype=VALETING [NC,L,N]

RewriteRule ^sales\.*$ SALES\.php?subtype=SALES [NC,L,N]

 

order deny,allow

 

I did have another question which is how can I get the above URLS and many others in the same format into one set of rules.

 

eg. RewriteRule ^1$\.*$ 1$\.php?subtype=1$ [NC,L,N]

 

Obviously this is very incorrect Im just a bit stuck, and im not really making a lot of sense of some of the tuts out there!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.