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
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]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.