skip to Main Content

I’m trying to do the following : redirect ANY folder the user access to the root index and including the folder name in the url parameter.

For instance , if users acces www.site.com/200 , it will redirect to www.site.com/index.php?folder=200

The 200 folder does not exists, i just want the index.php to handle what user inputs as folder.

Here is what i tried :

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ ../index.php?folder=$1 [L] 

Somehow it’s not working, i get a 404 instead.

2

Answers


  1. I think the relative path is throwing it off; try:

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)$ /index.php?folder=$1 [L,NC] 
    
    Login or Signup to reply.
  2. Try this

      RewriteEngine on
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^([^/]+)$ /index.php?folder=$1[QSA,L]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search