Please help me with rewrite

Discuss practical ways rearrange URLs using mod_rewrite.

Please help me with rewrite

Postby alectsy » Wed Jun 11, 2008 7:50 pm

I have such problem
i have installed script and the .htaccess looks
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine on
RewriteRule .* - [env=REWRITE_ON:1]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [L]
</IfModule>

it does not work

i have added

Options +FollowSymLinks
RewriteEngine on

before, still does not work

remove
Options -MultiViews

nothing

then i search google and find someone had same problem
.htaccess looks

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.site\.com [NC]
RewriteCond %{REQUEST_URI} !^/index\.php.* [NC]
RewriteRule ^(.*)$ /index.php?q=$1 [L]
</IfModule>

everything works fine, only the url looks like this now
http://www.site.com/index.php?item/10

but it should be

http://www.site.com/item/10

How i can remove index.php? from url
or what should be changed or added to the original .htaccess

Thank you in advance!
alectsy
 
Posts: 16
Joined: Tue Dec 26, 2006 2:34 pm

Postby alectsy » Fri Jun 13, 2008 6:23 am

Ok! Tell me please what this part means
RewriteRule .* - [env=REWRITE_ON:1]

Thank you
alectsy
 
Posts: 16
Joined: Tue Dec 26, 2006 2:34 pm

Postby richardk » Fri Jun 13, 2008 2:40 pm

Tell me please what this part means
RewriteRule .* - [env=REWRITE_ON:1]

It sets a variable ion the PHP script (probably $_SERVER['REDIRECT_REWRITE_ON'] = 1;).

Try
Code: Select all
Options +FollowSymLinks -MultiViews

RewriteEngine On

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?url=$1 [QSA,E=REWRITE_ON:1,L]


OR
Code: Select all
Options +FollowSymLinks -MultiViews

RewriteEngine On

RewriteCond %{REQUEST_URI} !^/index\.php$ [NC]
RewriteRule ^(.*)$ /index.php?url=$1 [QSA,E=REWRITE_ON:1,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 82 guests

cron