.htaccess ModReWrite Help

I am having problems with the ReWrite code. Please note that the .htaccess file is located in the subdomain folder (... public_html / subdomain /)

I'm just trying to rewrite the page request:

http://subdomain.mysite.com/home
http://subdomain.mysite.com/index.php?page=home

      

My .htaccess file looks like this:

RewriteEngine On
RewriteRule ^/([A-Za-z0-9\-\_])$ /index.php?page=$1

      

Does anything jump out at you?

0


a source to share


3 answers


Your current rule probably works for URLs that are one character long (after the forward slash)!

Add +

to represent one or more characters, or *

for zero or more



Try

RewriteEngine On
RewriteRule ^/([A-Za-z0-9\-\_]*)$ /index.php?page=$1

      

+3


a source


If you want to use rules in the .htaccess file, you need to remove the prefix of the context directory path from the template RewriteRule

. If the .htaccess file is in the document root /

, you need to remove the presenter /

.

Also, you need to quantify the character set. Otherwise, it will only describe one character.



So try this rule:

RewriteRule ^([A-Za-z0-9-_]+)$ index.php?page=$1

      

+2


a source


I think,

RewriteRule ^([^/]*)$ /index.php?page=$1 [L]

      

fine;)

0


a source







All Articles