简体   繁体   中英

RewriteRule not working

I am trying to create friendly urls with .htaccess. I have checked and if I put deny from all on my .htaccess it does not load the webpage proving that the .htaccess is working.

I also have verified that mod-rewrite module is loaded on php using phpinfo The problem is that when I access the url http://128.199.62.16/web/grupo/asd/123 it say not found and when i try with http://128.199.62.16/web/grupo/index.php?id=asd&description=123 it works as expected

Here you can find my .htaccess file content

RewriteEngine on
RewriteRule ^web/grupo/([^/]*)/([^/]*)/$ web/grupo/index.php?id=$1&descripcion=$2
Options -Indexes
ServerSignature Off

Can you please help me :D

Your input URL does not have a trailing slash, but your rule expects one.
I suggest putting a question mark after the trailing slash to indicate that it is optional.
Also, I suggest using + instead of * to indicate "one or more" rather than "zero or more".

RewriteRule ^web/grupo/([^/]+)/([^/]+)/?$ web/grupo/index.php?id=$1&descripcion=$2

For further reference, see:
trailing slash optional

Create a new file /var/www/html/web/grupo/.htaccess if it doesn't exist with this rule:

RewriteEngine on
RewriteBase /web/grupo/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?id=$1&descripcion=$2 [L,QSA]

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