RewriteRule issue
Posted by: MBourne (---.134.182.58.starhub.net.sg)
Date: March 04, 2019 10:22AM

(I posted this on StackExcahnge but got no responses. Hoping someone here can suggest a solution.)

I want to enter localhost/expl/admin/add-edit-category/ and have it process localhost/expl/admin/add-edit-category.php

The following .htaccess works fine on two different production servers, but results in a 404 on localhost (Wampserver 3.1.3, Apache 2.4.33, PHP 7.1.16)

RewriteBase /expl/
RewriteRule ^admin/([A-Za-z0-9-]+)/?$ /expl/admin/$1\.php [QSA,NC,L]
However, if I do something like this, it's fine on Wampserver:

Enter: localhost/expl/dummy-dir/admin/add-edit-category/

RewriteRule ^([A-Za-z0-9-]+)/admin/([A-Za-z0-9-]+)/?$ /expl/admin/$2\.php?dir=$1 [QSA,NC,L]
It will read the variables just fine and everything works as expected. So why is the first case falling over?

Another related issue (which is resulting in "too many redirect" errors) is localhost already allows entering URIs without file extensions, so e.g.

localhost/expl/admin/add-edit-category in the address bar processes
localhost/expl/admin/add-edit-category.php,

but I don't want it to do so (it's not how it works on the production servers and I need it to be consistent on my local machine). I can't find any settings in Wampserver that cause this, so I haven't been able to edit it.

Options: ReplyQuote
Re: RewriteRule issue
Posted by: Otomatic (Moderator)
Date: March 04, 2019 10:56AM

Hi,

The first thing to do is to check that the Apache and PHP versions as well as the loaded Apache modules and PHP extensions are the same between the production server and the local server.

In addition, it would be necessary to:
- Verify that all VC ++ packages are installed and with the latest versions.
To do this, use the tool:
Checks VC++ packages installed
Do not use a previously loaded tool. Make a new download to make sure you are using the correct version.
To download missing packages, do not rely on Microsoft links, they are not reliable, download packages on http://wampserver.aviatechno.net in section Visual C++ Redistribuable Packages
Do not forget that if you have a 64 bit Windows, you must install both 32 and 64 bit versions of each package.
You must install each package "as an administrator", so right-click the exe file and then run as Administrator.

- Apply Update 3.1.7 to your version of Wampserver
Wampserver update 3.1.7

> Enter: localhost/expl/dummy-dir/admin/add-edit-category/
The second thing to do - but which must be the main one - is to do as with hosting providers, i. e. to use VirtualHost:
see The need for Virtual Host and Wampserver 3 - Create or add a VirtualHost

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons



Edited 1 time(s). Last edit at 03/04/2019 10:59AM by Otomatic.

Options: ReplyQuote
Re: RewriteRule issue
Posted by: MBourne (---.134.182.58.starhub.net.sg)
Date: March 05, 2019 09:14PM

Thank you for your help. I did what I could from your list of suggestions, but the behaviour persisted.

In the meantime, someone responded to my same question on Stackexchange and suggested turning off Multiviews in httpd-vhosts.conf, and that fixed both issues.

Options: ReplyQuote


Sorry, only registered users may post in this forum.