Jump to content

RewriteRule On Uppercase Words


The Little Guy

Recommended Posts

I was using this mod rewrite:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.+?)$ /page.php?name=$1 [L,QSA]

 

I needed to change line 4, I want a url to look like this:

http://site.com/TheLittleGuy

 

So that worked, but now I need to change it a little bit.

 

I need it so only the part after the slash applies to words that starts with an uppercase letter or a number. other that that I don't want that rewrite to apply to the name after the slash.

 

Any suggestions on a fix for this?

 

I have tried this, but it doesn't work:

RewriteRule ^(([A-Z]|[0-9]).+?)$ /page.php?name=$1 [L,QSA]

 

It works if the name is uppercase, but if not, it can't find the file

 

http://site.com/TheLittleGuy <- Works

http://site.com/help <- Doesn't work, and this file does exist

Link to comment
https://forums.phpfreaks.com/topic/179275-rewriterule-on-uppercase-words/
Share on other sites

OK... It does work, but only if I put help.php

 

how do I remove the php extension?

 

Using this removes the extension (last line), but it doesn't work along with the second to last line, if I comment out the second to last line, then I can do http://site.com/help otherwise having them both active breaks the site...

 

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(([A-Z]|[0-9]).+?)$ /page.php?name=$1 [L,QSA]
RewriteRule ^(.*)$ $1.php [L,QSA]

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.