Hi,

I have the following htaccess file:

<IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteEngine on
    RewriteBase /

    RewriteCond %{REQUEST_FILENAME} -f [NC,OR]
    RewriteCond %{REQUEST_FILENAME} -d [NC]
    RewriteRule .* - [L]

    DirectoryIndex /index.php

    RewriteRule ^([^/.]*)$ $1/ [R]
    RewriteRule ^([^/.]*)/$ /$1.php [QSA]

</IfModule>

This works fine, if I put for example /legal/ it loads up legal.php however if legal.php didnt exist I need it to put index.php?username=legal

Can this be done?

Thanks,
Daniel

Member Avatar for diafol

What's wrong with a 404?

This seems to be dual purpose. Are you looking for a fallback?

Prob best to have a rewrite to /users/legal/

No, what I am trying to do is use the /filenotexists/ to be a dynamic username so you can put /anything but if /anything is a .php file in the root it will show that, if its not a .php file in the root it will add it to index.php?username=anything

Hope this makes sence?
Thanks

Member Avatar for diafol

I thought the answer in the link I gave addressed that.

You are correct! Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.