开发者

Whats wrong with this htaccess line

开发者 https://www.devze.com 2023-03-28 05:37 出处:网络
I have these lines in my .htaccess RewriteEngine On RewriteCond %开发者_运维问答{REQUEST_FILENAME} !-f

I have these lines in my .htaccess

RewriteEngine On
RewriteCond %开发者_运维问答{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^restaurant_pos$ index.php?route=$1 [L]

but if you visit the site here then you will see the top left corner my php debug statement

echo print_r($_REQUEST);

which prints

Array
(
    [route] => 
)

Why is it empty.....this is causing issues...what am i doing wrong


You are referencing a replacement variable $1 which does not exist. These are defined with parenthesis, like this:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^restaurant_pos_([0-9]+)$ index.php?route=$1 [L]

This will for example match a number in the url after restaurant_pos and put it into the GET parameter route.

http://www.example.com/restaurant_pos_1234 

will result in

index.php?route=1234

Or if you are trying to get everything:

RewriteRule ^(.*)$ index.php?route=$1

should return everything after the domain name in the GET parameter route.


Replace

RewriteRule ^restaurant_pos$ index.php?route=$1 [L]

with

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


Try to use $0 instead. Alternatively, try to add a capturing group (parenthesis around whatever should go in $1).

RewriteRule ^(restaurant_pos)$ index.php?route=$1 [L]
0

精彩评论

暂无评论...
验证码 换一张
取 消