Blake M
Blake M

Reputation: 41

Mod_rewrite question

It is possible to rewrite my url using mod_rewrite and htaccess where a user could enter:

http://www.mainsite.com/12345

which the server would translate as:

http://www.mainsite.com/index.php?ID=12345

By also trying to remove the file extension from all pages, (remove .php) it conflicts and causes a never ending redirect:

<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)\.php$ $1 [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9a-zA-Z]+)$ index.html?ID=$1 [QSA,NC,L,R]
</IfModule>

Upvotes: 0

Views: 53

Answers (1)

Zimbabao
Zimbabao

Reputation: 8240

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9]+)$ index.php?ID=$1

Upvotes: 1

Related Questions