2

The software I am working on uses ugly urls. To make it easier for users to share projects (it is a project administration package) I want to have a redirect. It should redirect projectadmin.dev/project/1234 to some other URL. I can get this to work on ISS using their web.config files, but Apache is giving me headaches.

For demo purposes I have shortend my current .htaccess file, but it still gives the issue:

RewriteEngine On
RewriteRule ^.*project/([0-9]+)$ RandomOtherPage.php  

When I access the url projectadmin.dev/project/123 it gives me an 403 (Forbidden) error. I think this happens because the folder project exists in my project. When I change the .htaccess file to:

RewriteEngine On
RewriteRule ^.*projects/([0-9]+)$ RandomOtherPage.php 

And go to projectadmin.dev/projects/123 it will work as I intended.

My question: How do I ignore the fact the project folder exist but still have the files in it accessable (eg. projectadmin.dev/projects/image.jpg should still work) and have a working redirect with the digits?

2
  • Do you have another .htaccess file inside the /project folder that also contains mod_rewrite directives?
    – MrWhite
    May 16, 2017 at 14:31
  • No nothing is there, just pictures and some other random files
    – thomas479
    May 16, 2017 at 14:38

1 Answer 1

0

Try disabling MutliViews. At the top of your .htaccess file:

Options -MultiViews

Unless you had a .htaccess file located in the /project subdirectory, that also contained mod_rewrite directives, then there shouldn't be a problem if the folder exists or not.

1
  • I created the .htaccess file in the /project subdirectory and removed the RewriteRules from the root .htaccess file. This worked, the Options -MultiViews did not work for me, even if I included it in <IfModule mod_negotiation.c>.
    – thomas479
    May 16, 2017 at 14:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .