Redirect Problem

New to mod_rewrite? This is a good place to start.

Redirect Problem

Postby soloam » Fri May 04, 2007 5:23 am

I have a small web site that I what to have a easy link.

A link like:

http://mysite/?var1=v1

Will apear like
http://mysite/var1/v1/

I have whriten the rewrite code to:
RewriteEngine on
RewriteRule ^var1/([a-z_]*)/{0}$ http://mysite/var1/$1/ [R]
RewriteRule ^var1/([a-z_]*)/$ http://mysite/index.php?var1=$1

But now all my images and scripts are gone... the browser is looking for them in: (example)

http://mysite/var1/v1/images/img1.jpg

When the corect path is:

http://mysite/images/img1.jpg

He is assuming the new link has a path.

Can any one help me?
soloam
 
Posts: 5
Joined: Fri May 04, 2007 5:10 am

Postby richardk » Fri May 04, 2007 12:18 pm

The problem is relative paths.

Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^(var1/[a-z_]+)$ http://www.domain.com/$1/ [R=301,L]
RewriteRule ^var1/([a-z_]+)/$ /index.php?var1=$1 [L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby soloam » Wed Jun 10, 2009 11:21 am

Hello I have one question!

Di any one knows way to detect using Mod_Rewrite if a user is accessing a page via reload button or via a link?

Best Regards
soloam
 
Posts: 5
Joined: Fri May 04, 2007 5:10 am

Postby richardk » Wed Jun 10, 2009 1:28 pm

As far as i know there is not way. I think the HTTP requests would be the same.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 98 guests

cron