•
•
•
•
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
![]() |
•
•
Join Date: May 2007
Location: London
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
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!
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!
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Linux Servers and Apache Marketplace
•
•
•
•
apple bbc cd cellphone choose code computer core debian dell desktop development drivers enterprise fedora fiji games gentoo gpl hardware ibm infrastructure install kernel laptop linux marketing microsoft mobile news novell open open source openoffice operating os palm preinstall red hat rhel security server source sun system ubuntu unix vista web windows
- php5 and phpmyadmin?? (PHP)
- "Forbidden / You don't have permission to access / on this server." error (Linux Servers and Apache)
- session_start(): Cannot send session cache limiter - (PHP)
- session_start(): Cannot send session cache limiter - (PHP)
- This Should be Easy for You Guys! (Linux Servers and Apache)
- another newbie with alot of redhat and apache server Q'S (Linux Servers and Apache)
- $_SESSION and session.auto_start do not store data (PHP)
- Windows Api Tutorial (C++)
Other Threads in the Linux Servers and Apache Forum
- Previous Thread: mod rewrite apache
- Next Thread: Hacking chmod 777 folder


Linear Mode