Home Rewriterule -> 500 internal error with .htaccess
Reply: 1

Rewriterule -> 500 internal error with .htaccess

Luca Published in 2017-12-06 09:58:34Z

I tried everything for my problem, but nothing works.

I'm not familiar with regex, but I did my best.

Here is the code:

Options +FollowSymlinks

RewriteEngine on

RewriteRule ^series/([A-Z]+)?$ series.php?code=$1 [L,QSA,NC]
RewriteRule ^exercices/([A-Z]+)-([0-9]+)/([0-9]+)?$ exercices.php?code=$1&serie=$2&question=$3 [L,QSA,NC]

# Remove php extension
RewriteCond %{REQUEST_FILENAME}.php -f 
RewriteRule ^(.*)$ $1.php [L]

# Redirect to HTTPS
RewriteCond %{HTTPS} !=on
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

# Redirect to 404 if url is not correct
RewriteCond %{THE_REQUEST} \s.+?\.php[\s?] [NC]
RewriteCond %{REQUEST_URI} !/index\.php [NC]
RewriteRule ^ https://www.test.com/404 [L]

# Errors
ErrorDocument 404 https://www.test.com/404
ErrorDocument 403 https://www.test.com/
ErrorDocument 500 https://www.test.com/

With that, I have a beautiful 500 internal error...

I've really did some research, but I'm still stuck.

Can someone help me please ? (sorry for my bad english)

Luca Reply to 2017-12-06 13:20:43Z

I just added " /? " just before the " $ " sign, and it's working :

RewriteRule ^series/([A-Z]+)/?$ /series.php?code=$1 [L]
RewriteRule ^exercices/([A-Z]+)-([0-9]+)-([0-9]+)/?$ /exercices.php?code=$1&serie=$2&question=$3 [L]

I hope it will help for people who have the same issue.


You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.314915 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO