I now have a Laravel installation with the default folder structure.
In my root folder I have a .htaccess file like this one.
Options +FollowSymLinks
<IfModule mod_rewrite.c>
# RewriteEngine On
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteRule ^ index.php [L]
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
I have to install in a subfolder WordPress.
So I would like to access to my WP installation using the URL http://www.example.com/ and to Laravel with http://www.example.com/admin.
The thing I know it's that is an .htaccess trick, but, even if I tried many kind of rewrites, I'm not still able to achieve the desired result.
So, in your root .htaccess you should use the following:
RewriteEngine On
# Route any request begining with 'admin/' to laravel
RewriteRule ^admin/(.*)$ public/$1 [L]
# Anything else goes to Wordpress
RewriteRule ^(.*)$ wp/$1
And in your Laravel .htaccess add:
RewriteBase /admin
If you can't live with the trailing slash being mandatory you can try:
RewriteRule ^admin(/(.*))?$ public/$2 [L]
Try this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /your-subdirectory/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /your-subdirectory/index.php [L]
</IfModule>
# END WordPress
Related
i have a problem with the htaccess file from a system which i bought.
The Original File looks like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
My modified version looks like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^city-([^/]+).html searcharea?city=$1&sd=ls [L]
RewriteRule ^city-normal-([^/]+).html searcharea?city=$1&sd=pb [L]
RewriteRule ^city-special-([^/]+).html searcharea?city=$1&sd=oeb [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
The Systems Base Home Link looks like this:
http://www.url.de/store/home
and my .htaccess is completely ignored, i wonder why?
i want to include a seo linking to the system and reffer its url to the function but it doesnt work with this htaccess.
i have this htaccess rules in my other htaccess file from another system and there it works perfectly.
edit:
the rules from original file work, just my rules are ignored. mod_rewrite is enabled
Structure of my dirs:
/
/.htaccess
/index.php -> uses yiiframework to build pages
/core
/core/css
/core/js
This is because your orignal htaccess rules are conflicting with the new rules and they rewrite all non existent requests to index.php. To fix this, you need to reorder your rules .
Try :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^city-([^/]+).html searcharea?city=$1&sd=ls [L]
RewriteRule ^city-normal-([^/]+).html searcharea?city=$1&sd=pb [L]
RewriteRule ^city-special-([^/]+).html searcharea?city=$1&sd=oeb [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Make sure that mod_rewrite is enabled in apache on your server.
I have several hosted clients and several subdomain clients, and I'd like to write .htaccess or php.ini rules to allow each of these sites, including my root site to have access to a common folder (/home/usr/public_html/public_scripts/) public that the clients (/home/usr/public_html/subdomains/client/) or (/home/usr/public_html/hosts/clients/) cannot see in ftp, but the root site can:
/home/usr
|--/public_html
|--/public_scripts/
|
|--/hosts
| |--/client
| |--/subdomains
|
|--/subdomains
|--client
So that I can use this folder from:
www.mydomain.com/public_scripts/
subdomain.mydomain.com/public_scripts/
www.theirdomain.com/public_scripts/
subdomain.theirdomain.com/public_scripts/
I've tried:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^common/(.*)$ /home/usr/public_html/public_scripts/$1 [QSA]
</IfModule>
But this did not work. It simply redirects to /index.php
Shared hosting, so I do not have access to the httpd-conf file. I do have access to php.ini
it is matching correctly when I turn the WP rules off. I have both subdomain and domain mapping in my site, but I'm not sure if I need wp both sections or if I can combine all three into one rewrite rule.
Edit: Here's the rewrite rules I'm using, now that I realized I'm on a wordpress HTACCESS:
<IfModule mod_rewrite.c>
# BEGIN Wordpress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
# END Wordpress
</IfModule>
<IfModule mod_rewrite.c>
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^common/(.*)$ /home/usr/public_html/public_scripts/$1 [QSA]
</IfModule>
AddHandler application/x-apple-aspen-config .mobileconfig
But this did not work. It simply redirects to /index.php
Shared hosting, so I do not have access to the httpd-conf file. I do have access to php.ini
It is matching correctly when I turn the WP rules off. I have both subdomain and domain mapping in my site, but I'm not sure if I need wp both sections or if I can combine all three into one rewrite rule.
Here's the "working" htaccess. Some day I'll have to organize these when I have more time:
<IfModule mod_rewrite.c>
# BEGIN Wordpress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
# END Wordpress
</IfModule>
<IfModule mod_rewrite.c>
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# END WordPress
RewriteRule ^common/(.*)$ /home/usr/public_html/public_scripts/$1 [QSA]
# BEGIN WORDPRESS
RewriteRule . /index.php [L]
# END WORDPRESS
</IfModule>
AddHandler application/x-apple-aspen-config .mobileconfig
Seems like this rule is a catch all: RewriteRule . /index.php [L]. It will matching anything. Move your rule up.
Hello I am new user in symfony please solve my issue
I am writing the into the .htacess file is
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /web/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>
Or
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
# Explicitly disable rewriting for front controllers
RewriteRule ^app_dev.php - [L]
RewriteRule ^app.php - [L]
RewriteCond %{REQUEST_FILENAME} !-f
# Change below before deploying to production
#RewriteRule ^(.*)$ /app.php [QSA,L]
RewriteRule ^(.*)$ /app_dev.php [QSA,L]
</IfModule>
Both are also work into the home page but not in sub pages like
http://demo.co.uk/
but not this
http://demo.co.uk/app_dev.php/services
So how to remove 1app_dev.php1, I wanna just like this
I think you are mixing up the two environments.
app_dev.php is your development version, it shouldn't be a requirement to remove it as you can see it only in development.
app.php is your default environment, which is production. That should be the one which is hidden from the users.
Anyway, if you still want to do this, you have to replace the RewriteRule only. Try this .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /web/
RewriteCond %{REQUEST_FILENAME} !-f
# Change below before deploying to production
#RewriteRule ^(.*)$ app.php [QSA,L]
RewriteRule ^(.*)$ app_dev.php [QSA,L]
</IfModule>
Here is my folder structure
www.mywebsite.com
www.mywebsite.com/app
www.mywebsite.com/app/firstproject
www.mywebsite.com/app/secondtproject
In the root directory i installed wordpress. It allows me to access the www.mywebsite.com/app but when i try to access the www.mywebsite.com/app it is always showing page not found i can guess that it is because of the .htaccess at the root folder.
Here is the .htaccess root folder
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I tried to override the .htaccess to the sub folders by having the below code in the .htaccess of the app folder but it shows the same page not found error.
RewriteRule ^app/ - [L]
How can i access the www.mywebsite.com/app/firstproject without that error ?
Remove app/.htaccess
Have this code in root .htaccess:
root .htaccess:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(index\.php$|app/) - [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
# END WordPress
Write all rules in the root htaccess file.
add
RewriteRule ^app/firstproject$ - [L]
to prevent rewrite in this path.
For further rewrite within /firstproject, you need conditions and rules similar to web root
RewriteEngine On
RewriteBase /
RewriteRule ^app/firstproject$ - [L] #add longer path first
RewriteRule ^index.php$ - [L] #no need to escape \.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
I'm having some issues with a Codeigniter app in a subfolder on my server along with a Wordpress install in the document root. If I hide the index.php of the Codeigniter URL with .htaccess
/codeigniter/.htaccess
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|user_guide|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
And get Wordpress to ignore /codeigniter with RewriteCond %{REQUEST_URI} !^/(codeigniter).*$
/.htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_URI} !^/(codeigniter).*$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Then navigate to www.mysite.com/codeigniter/my_controller/my_function, I get a 404 error No input file specified. I found here, that adding a ? after RewriteRule ^(.*)$ index.php solves the Codeiginiter 404 error.
/codeigniter/.htaccess
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
However I'm now getting a Wordpress 404 error, so it seems if I replace index.php with index.php? in /codeigniter/.htaccess, the Wordpress rewrite rule in /.htaccess, RewriteCond %{REQUEST_URI} !^/(codeigniter).*$ gets ignored. Is there a better way to handle this?
Thanks in advance!
The RewriteBase in the codeigniter directory should say /codeigniter/
RewriteBase /codeigniter
Otherwise the rewrite to index.php ends up going to wordpress' router.