Reputation: 1473
I'm trying to mod_rewrite:
localhost/edit.php?title=?&user_id=?
To:
localhost/edit/<?php echo $title.'/'.$user_id; ?>
So, I can output links as a loop
echo '<a href="localhost/edit/'.$title.'/'.$user_id.'">'.$title.'</a>';
I'm using:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#Reroute through index.php
RewriteRule ^([a-zA-Z0-9_]+) index.php?title=$1 [NC]
#this is RewriteRule for edit.php UPDATED:
RewriteRule ^/?edit/([a-zA-Z0-9_]+)/([0-9]+)$ edit/index.php?title=$1&user_id=$2 [NC,L]
However, I get this error:
This webpage has a redirect loop
Upvotes: 0
Views: 551
Reputation: 45589
Try this
Options +FollowSymLinks
RewriteEngine On
# /edit/title_here/123 -> edit.php?title=title_here&user_id=123
RewriteRule ^edit/([A-Za-z0-9_]+)/([0-9]+)$ edit.php?title=$1&user_id=$2 [NC,L]
#Reroute through index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([A-Za-z0-9_]+) index.php?title=$1 [NC,L]
Upvotes: 2