User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Linux Servers and Apache section within the Tech Talk category of DaniWeb, a massive community of 391,138 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,147 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Linux Servers and Apache advertiser:
Views: 1459 | Replies: 0
Reply
Join Date: May 2007
Location: London
Posts: 1
Reputation: Krakatoa is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Krakatoa Krakatoa is offline Offline
Newbie Poster

Adding a trailing slash

  #1  
May 16th, 2007
In my website I have all the links are relative and look like var1/ or var1/var2/

I want to redirect them to index.php?p=var1 or index.php?p=var1/var2 without changing the address in the address bar. So I did this:

RewriteEngine on
RewriteRule ^(.+)/$ index.php?p=$1 [QSA,L]

and it works fine.
But I'd also like to send relative links like var1 and var1/var2 to the same index.php?p=var1 and index.php?p=var1/var2, so I modified the .htaccess like this:

RewriteEngine on
RewriteCond %{SCRIPT_FILENAME}!^index\.php$
RewriteCond %{SCRIPT_FILENAME}!^.+/$
RewriteRule ^(.+)$ $1/ [are=301]
RewriteRule ^(.+)/$ index.php?p=$1 [QSA,L]

obviously it doesn't work as I hoped... but why?

Thanks!
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Linux Servers and Apache Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Linux Servers and Apache Forum

All times are GMT -4. The time now is 6:39 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC