简体   繁体   中英

.htaccess: Rewrite dynamic url with static url

I want to enter http://localhost:81/admin/dashboard in my browser but the request should be http://localhost:81/admin/index.php?page=dashboard .

The mod_rewrite is enabled and i tried this in the .htaccess but it didn't work. The .htaccess is located in htdocs/admin/.htaccess:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ index.php?page=$1  [NC]

You can match the trailing slash optionally by adding a ? next to it in the pattern :

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ index.php?page=$1  [NC]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM