I’m currently getting to grips with mod_rewrite and have ran into a stumbling block which i was hoping someone would be kind enough to help
I have a site that is structured as so
https://www.abc.com/region1/
https://www.abc.com/region2/
https://www.abc.com/region3/
Within each of these folders lies two files i’ll call example1.php and example2.php, both are dynamic
Regarding example1.php a possibility might be example1.php?var1=1
Regarding example2.php one possibility might be example2.php?var1=1&var2=1
I’ve been trying to use the following but its throwing a server 500 error
RewriteEngine On
RewriteRule ^example1alias/ example1alias/([^/\.]+)/?$ example1.php?var1=$1 [L]
RewriteRule ^example1alias/ example1alias/?$ example1.php [L]
RewriteRule ^example2alias/ example2alias/([^/\.]+)/([^/\.]+)/?$ example2.php?var1=$1&var2=$2 [L]
My .htaccess containing this code is located in the subfolder itself and if i understand mod_rewrite correctly the ^ tells the rule to run from the active path
Could someone point out what i’m doing incorrectly
As always any advise is greatly appreciated
Regards
Barry
Most of the times HTTP 500 (for htaccess) are for syntax errors in the htaccess file.
For rewrite rules I believe the syntax is: RewriteRule Pattern Substitution [flags]
(http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriterule)
You seem to have more than one patterns for one rule, maybe you can try separating them out into 2 different rules.
Also add “RewriteEngine On” and “Options FollowSymLinks” to your htaccess file