Forum Moderators: phranque

Message Too Old, No Replies

Rewrite help

         

hOtTiGeR123

5:05 pm on Jun 15, 2008 (gmt 0)

10+ Year Member



Hi,

I'm using an .htaccess to remove the .php extension via the following:

RewriteEngine On
RewriteBase /

# Externally redirect direct client requests for .php files to non-.php URLs
RewriteCond %{THE_REQUEST} ^GET\ /([^/]+/)*[^.]+\.php(\?[^\ ]*)?\ HTTP/
RewriteRule ^(([^/]+/)*[^.]+)\.php$ [abc.localhost...] [R=301,L]

# Internally rewrite extensionless page URLs to php files if no extension or trailing slash on requested URL
RewriteCond %{REQUEST_URI} !(\.¦/$)

# and if filename exists when .php is appended
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule (.+) /$1.php [L]

Anyway is there a way I can rewrite this url:

[abc.localhost...]

to

[abc.localhost...]

Thanks

[edited by: hOtTiGeR123 at 5:06 pm (utc) on June 15, 2008]

jdMorgan

5:50 pm on Jun 15, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Your code does not remove anything, actually, it adds ".php" to the URL requested by the client. Since the terminology you used was a bit fuzzy there, I need to ask:

Which one of those two URLs do you actually use in links on your pages?

Jim

hOtTiGeR123

8:17 pm on Jun 15, 2008 (gmt 0)

10+ Year Member



Okay well the actual url used is [abc.localhost...]

but I would like it to be just [abc.localhost...]

jdMorgan

2:14 am on Jun 16, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



So you want to rewrite a request for the URL [abc.localhost...] to the server filepath /contact/xyz, is that right? Please post your best-effort code as a basis for discussion [webmasterworld.com].

Thanks,
Jim

hOtTiGeR123

6:25 am on Jun 16, 2008 (gmt 0)

10+ Year Member



Yes basically, but not have it show up as /xyz and just show the requested url.

Thanks