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.
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
Related
My system is MAC and I am running Xampp for mac.
I search for many solutions and I thought it must be because of my .htaccess missing file , that all my rest of the links in wordpress even my posts, page except my homepage redirects to localhost/dashboard which is xampp's dashboard.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
This is my .htaccess file , and I have all set
<Directory />
AllowOverride all
Require all denied
</Directory>
in apache httpd.conf file
Now what else I can do? I am stuck with this, Even when I click the permalink on my wp-admin page, it shows no object found, 404 error. The page exits, the post exists, everything exists and still I can see only homepage.
Since WordPress seems to be located in /wordpress/, change RewriteRule . /index.php [L] to RewriteRule . /wordpress/index.php [L]?
Should be something like this
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
# END WordPress
after hours of search I found that I need to give write permission for my root wordpress folder, hence it was achieved by
sudo chmod -R 777 wordpress
Check your htaccess file. for local version, you need to declare your root folder on the last RewriteRule before the index.php for it to work
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /rootfolder/index.php [L]
</IfModule>
I've spent much time to find out this trouble, that my cakephp running on my localhost server, but when I move my cakephp to hosting server, cakephp just shows blank page, anyone have codes .htaccess in root folder, cakephp folder, and another that need for my cakephp running on server ?
for your information, my cakephp version is cakephp 3
I've tried with this code
in root .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
in my folder cakephp .htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /my_app_name
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
in my webroot folder
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
for many tutorial that I've read, they said we have set 3 .htaccess file, is there any wrong code in my .htaccess file so I cannot access my website?
[CASE CLOSED]
The solutions is just make sure your php already enable intl in your hosting / shared server
I am using this htaccess for my application.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Any URL I will type in my browser, if the respective file doesn't exist, it will open the index.php.
The problem is I have many applications like this installed on the same domain.
For example, the root contains an index.php file and a htaccess like above.
I have also, /store, which contains a index.php file and a htaccess like above, too, but when I access /store/something it opens the index.php of root (not the correct /store/index.php
How can I solve this problem (how to make the htaccess of root to not override the htaccess of /store)? Thanks!
You can have a skip directory rule to skip all the directories:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# skip index.php and some directories
RewriteRule ^(store/|site1/|site2/|index\.php$) - [NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
i get a 403 when i browse to the root directory of my laravel project. When i go to root/public i do get a you have arrived message from the framework. But this isnt what is supposed to be right? How do i make my project so that when i go to the root i actually get into /public?
i have tried the following:
This is how my htaccess file looks like in in the root:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
You need to set DocumentRoot properly in your Apache configuration. This is separate from the .htaccess and it should point at the public directory.
If you can't configure apache directories, for production environment, put 2 .htaccess files.
The 1. is in the root folder:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
The 2. is in the /public folder:
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
I have deployed a PHP web application on my host (root of my host) now i want to install a web analytic php web application in a folder called "stat" (in the root of my host as a sub domain) but ".htaccess" file in the root of first PHP application does not allow to access "stat" folder how can i config ".htaccess" file to allow map stat.mydomain.com to "stat" folder.
This is ".htaccess" file located in the root of my host:
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . %1/%2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php?qa-rewrite=$0&%{QUERY_STRING} [L]
</IfModule>
I wish i can describe my problem clearly. please help me as soon as possible.
Thanks in advance.
First thing first I hope you have a VirtualHost entry in your httpd.conf for subdomain stat.mydomain.com as commented by faa.
Once you have that working change your $DOCUMENT_ROOT/.htaccess with this:
DirectoryIndex index.php
Options +FollowSymLinks -MultiViews
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php?qa-rewrite=$0 [L,QSA]
</IfModule>