I want to serve wordpress from public_html/blog. I have already install zend framework and i would like to know how to achieve this. My .htaccess file looks like
RewriteEngine On
RewriteRule ^\.htaccess$ - [F]
RewriteCond %{HTTP_HOST} ^domain\.example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.domain\.example\.com$
RewriteRule ^/?$ "http\:\/\/simple\.com\/" [R=302,L]
RewriteCond %{HTTP_HOST} ^other\-domain\.example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.other\-domain\.example\.com$
RewriteRule ^/?$ "http\:\/\/simple\.com\/" [R=302,L]
RewriteCond %{REQUEST_URI} =""
RewriteRule ^.*$ public/index.php [NC,L]
RewriteCond %{REQUEST_URI} !^/public/.*$
RewriteRule ^(.*)$ /public/$1
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [NC,L]
RewriteRule ^public/.*$ public/index.php [NC,L]
I am totaly green in htaccess files and this is my first case with it. Is that structure already correct?
In your ZF htaccess, allow apache to service existing files and directories:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
Now apache will see that /blog is a real folder and then load the htaccess inside there (your WP htaccess) when the user goes to /blog.
You should be able to have your two htaccess rules separate without the need for complex routing
Related
I have WP and Laravel6 with structure.
my_site/
.htaccess
wp/
laravel/.htaccess
and virtualhost
<VirtualHost subdomain.local:777>
DocumentRoot "c:\xampp\htdocs\my_site"
ServerName subdomain.local
</VirtualHost>
As I want to serve landing page from WP, I do bit changes in root .htaccess to remove wp from url
RewriteEngine on
# remove wp from urls
RewriteCond %{HTTP_HOST} ^subdomain.local:777$
RewriteCond %{REQUEST_URI} !^/wp/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /wp/$1
RewriteCond %{HTTP_HOST} ^subdomain.local:777$
RewriteRule ^(/)?$ wp/index.php [L]
now subdomain.local:777 shows wp landing page.
Next I want to eliminate laravel folder from urls which are serving from laravel ie:
subdomain.local:777/laravel/login to subdomain.local:777/login
subdomain.local:777/laravel/profile to subdomain.local:777/profile
and so on..
for that I add following into laravel/.htaccess but it crash all routes..
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^laravel/(.*)$ /$1 [L,NC,R]
with error
Object not found!
The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
If you think this is a server error, please contact the webmaster.
Error 404
subdomain.local
Apache/2.4.37 (Win32) OpenSSL/1.1.1 PHP/7.2.12
additionally my laravel/.htaccess file also configuring css/js/image/fonts to work like so
Options -MultiViews -Indexes
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.gif|robots\.txt|\.woff|\.woff2|\.ttf)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(css|js|images|google_map|image_compressor|admin-files|fontawesome-free|webfonts)/(.*)$ public/$1/$2 [L,NC]
or do I need to edit in c:\xampp\apache\conf\httpd.conf
Finally solved by bit changes in root .htaccess. such that the final version of .htaccess is now
RewriteEngine on
# remove wp from urls
RewriteCond %{HTTP_HOST} ^subdomain.local:777$
RewriteCond %{REQUEST_URI} !^/wp/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /wp/$1
RewriteCond %{HTTP_HOST} ^subdomain.local:777$
RewriteRule ^(/)?$ wp/index.php [L]
# Rewrite Laravel Routes
RewriteCond %{REQUEST_URI} !^/login [OR]
RewriteCond %{REQUEST_URI} !^/profile
RewriteRule ^(.*)$ laravel/public/$1 [L]
I am using Wordpress multisite and trying to set up IP redirects using the Apache GeoIP tool and an .htaccess file so that visitors are sent to the correct country site when visiting via my beta.mydomain.com address.
When first tested, I just receive a message saying it’s got stuck in a loop and:
ERR_TOO_MANY_REDIRECTS
Here is my existing code (Note: GeoIP is enabled elsewhere).
RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^GB$
RewriteRule ^(.*)$ https://uk.beta.mydomain.com/$1 [R=302,L]
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^DE$
RewriteRule ^(.*)$ https://de.beta.mydomain.com/$1 [R=302,L]
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^ES$
RewriteRule ^(.*)$ https://es.beta.mydomain.com/$1 [R=302,L]
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^US$
RewriteRule ^(.*)$ https://us.beta.mydomain.com/$1 [R=302,L]
# BEGIN WordPress
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
Adding this line at the top:
RewriteCond %{HTTP_HOST} !^(uk|us|de|es)\.beta\.mydomain\.com$ [NC]
improves things a little - the top one will now work, the others only when those above are commented out.
I presume there is something simple I am missing but I have only very limited understanding of this!
I am trying to create virtual subdomains using .htaccess and wordpress.
But it won't seem to work properly. Using wordpress I get urls like:
foo.eu/test-pagina/?lang=fr
I managed to rewrite this to what i want:
fr.foo.eu/test-pagina/
But when this url is rewritten the page returns an 500 internal server error.
I also made a wildcard for the subdomains in my dns configuration.
Do I have to make subfolders for each subdomain in my root ?
My current .htaccess code is:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^([a-z]{2})\.hypnose\.eu$ [NC]
RewriteCond %{THE_REQUEST} \ /+([^\?]*)\?lang=([a-z]{2})&?([^\ ]*)
#RewriteRule ^ http://%2.hypnose.eu/%1?%3 [L,R]
RewriteCond %{QUERY_STRING} !(^|&)lang=
RewriteCond %{HTTP_HOST} ^([a-z]{2})\.hypnose\.eu$ [NC]
RewriteRule ^(.*)$ /$1?lang=%1 [L,QSA]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Can anyone tell me what did I do wrong?
Have you added "fr" as your subdomain in the domain's control panel?
Add this in your htaccess
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.*)\.domain\.com
RewriteRule ^(.*)$ http://domain.com/test-pagina/%1/$1 [L,NC,QSA]
My site currently forces SSL everywhere. This is the way that I want except that it is causing issues with my RSS driven newsletter and feedburner. Due to this I need to make exceptions for my feeds.
Can someone help with the proper htaccess rules to pull this off?
My feeds are
/feed
/shop/feed
/forum/discussions/feed.rss
Here is my condition for forcing SSL. This works except that all RSS feeds are forced to.
# Force SSL
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !^/forum [NC]
RewriteRule ^/?(.*)$ https://photoboothowners.com/$1 [R=301,QSA,L,NE]
I tried the following but it did not seem to work correctly.
# Force SSL
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !^/forum [OR]
RewriteCond %{REQUEST_URI} !^/feed [OR]
RewriteCond %{REQUEST_URI} !^/shop/forum [NC]
RewriteRule ^/?(.*)$ https://photoboothowners.com/$1 [R=301,QSA,L,NE]
Your help is greatly appreciated!
Update: This is my current .htaccess file in the root of my server. This is currently redirecting http://photoboothowners.com/feed to https://photoboothowners.com (notice it is dropping the feed directory).
RewriteEngine on
# Use PHP5CGI as default
AddHandler fcgid-script .php
RewriteCond %{HTTP_HOST} ^buyaphotobooth\.net$ [OR]
RewriteCond %{HTTP_HOST} ^www\.buyaphotobooth\.net$
RewriteRule ^/?$ "https\:\/\/photoboothowners\.com\/starting\-a\-photo\-booth\-business\-build\-or\-buy" [R=301,L]
RewriteCond %{HTTP_HOST} ^photoboothforums\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.photoboothforums\.com$
RewriteRule ^/?$ "https\:\/\/photoboothowners\.com\/forum" [R=301,L]
# Force SSL
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} !^/forum [NC]
RewriteCond %{REQUEST_URI} !feed [NC]
RewriteRule ^/?(.*)$ https://photoboothowners.com/$1 [R=301,QSA,L,NE]
RewriteCond %{HTTP_HOST} ^photoboothowners\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.photoboothowners\.com$
RewriteRule ^how\-to\-use\-our\-premium\-print\-designs\-in\-breeze\-dslr\-remote\-pro\/?(.*)$ "https\:\/\/photoboothowners\.com\/how\-to\-use\-our\-photo\-booth\-template\-designs\-in\-breeze\-dslr\-remote\-pro$1" [R=301,L]
RewriteOptions inherit
# 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
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^shop\/photo\-booth\-layouts\-and\-samples\.html$ "https\:\/\/photoboothowners\.com\/shop" [R=301,L]
<Files 403.shtml>
order allow,deny
allow from all
</Files>
Your rules are using OR so they read as:
if server port is 80 and the request is not forum OR it is not feed OR it is not shop/forum
That's going to match everything. Get rid of both of the [OR] so that the match reads:
if server port is 80 and the request is not forum AND it is not feed AND it is not shop/forum
EDIT:
Per your updated question, the following line is missing a slash:
RewriteCond %{REQUEST_URI} !feed [NC]
should be
RewriteCond %{REQUEST_URI} !/feed [NC]
I have an application that uses Zend Framework but has a WordPress blog under the public directory (folder is named "blog").
Accessing the blog's homepage is fine, but when I try to access the posts, my htaccess rules have it go through Zend Framework. What do I need to modify in my /public/.htaccess file to have it ignore requests to the /public/blog directory?
Here's the current .htaccess file:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
Thanks!
I think, this should work
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/public/blog/
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]