0

I have a WordPress site hosted on AWS and I am having a hard time to configure mod_rewrite to work correctly.

Folder structure

/root
  |_ staging/
  |_ live/

The .htaccess is the WordPress default

<IfModule mod_rewrite.c>

  RewriteEngine On
  RewriteBase /
  RewriteRule ^index\.php$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.php [L]

</IfModule>

Main Problem

I can access /staging/index.php/api which I used to access it without subdirectories like this ---.com/api.

When I try /staging/api it shows File not found.

I tried to change the .htaccess to different thing but none of them was successful.

There are no .htaccess file in the root directory.

Some help would be appreciated =)

Thanks in advance.

1 Answers1

0

Try this code

<IfModule mod_rewrite.c>

  RewriteEngine On
  RewriteBase /staging
  RewriteRule ^index\.php$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /staging/index.php [L]

</IfModule>

Note: The AllowOverride should be set to All in server configuration. You can find the reference from here. How to Set AllowOverride all

  • I did try that in the `/staging/.htaccess` but didn't work – Nader S. Ikladious Apr 10 '19 at 10:05
  • Can you share you .htaccess code how you modified? Or else try with update this line `RewriteBase /staging` to `RewriteBase /staging/` – Evince Development Apr 10 '19 at 10:47
  • ``` # BEGIN WordPress RewriteEngine On RewriteBase /staging/ RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /staging/index.php [L] # END WordPress ``` that is the new `.htaccess` file I have tried both `/staging` and `/staging/` – Nader S. Ikladious Apr 10 '19 at 10:51
  • Strange thing. I am using the same and working for me. Have you checked this in your server configuration if everything is good? https://stackoverflow.com/questions/18740419/how-to-set-allowoverride-all Also can you please share your server configuration? – Evince Development Apr 10 '19 at 11:09
  • I changed the AllowOverride in the main apache configurations and it worked. Thanks very much – Nader S. Ikladious Apr 10 '19 at 12:33