简体   繁体   中英

(php) URL rewriting and 500 internal server error

I am having problems with this .htaccess that fires a 500 internal server error , the regex works as expected on regex101.com but here not.

Current URL: http://urlsite.com or http://urlsite.com?id=ID with optional &code=CODE

Desider URL: http://urlsite.com or http://urlsite.com/firstname-lastname-id with optional ?code=CODE

.htaccess

ErrorDocument 404 /404.php
ErrorDocument 403 /403.php

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^[\w-]+-([\w\d]+)\/*[?code=]*(\w*)$ http://localhost:8080/ index.php?id=$1&code=$2 [L,QSA]

Thanks to the comment of revo!

The error was the space before the "index.php" at the last line.

Thank you again :)

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