Reputation: 237
I have too many RewriteRule
inside .htaccess
.
Now i like to remove those RewriteRule
and use php to load or redirect my link.
For that i use header
but when i use it, my original urls in the browser are changing.
For example:
My original link: http://test.com/something/someID
, and when i use header, it change to : http://test.com/page.php?id=
Bottom line i need something like vbseo (vbulletin) to management my link without using RewriteRule
, but of course i have the below code inside .htaccess
to redirect all my link to some specific page.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php [L,QSA]
Upvotes: 0
Views: 862
Reputation: 1120
Im not exactly shure if this is what you asked for:
You could use a class like the Codeigniter URI class to get the single segments of your URI:
With the given segments you can now deside in your application what to do without hardcoding it into the .htaccess
Upvotes: 0
Reputation: 174967
Just don't give any headers. By default redirected links remain the same. (even though the server redirects them, it's transprent to the client). So you need to pass it to index.php but with a GET value of the original route.
So...
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f #If requested filename is not a file
RewriteCond %{REQUEST_FILENAME} !-d #If requested filename is not a directory
RewriteRule ^(.+)$ index.php?route=$1 [L,QSA]
So example.com/this/is/a/test
would redirect to example.com/index.php?route=this/is/a/test
which then you can check in your index.php file and reroute however you want based on that $_GET['route']
Upvotes: 1