Laravel pointing subfolder into other name - wordpress

I have a laravel project that include multiple domain inside.
I want to make the blog for each domain using wordpress. I already install the wordpress succesfully, but since this laravel project is a multiple domain inside, I install the wordpress project for each domain using "domainname_blog" on the public folder.
public_html
|- public
|- aa_blog
|- bb_blog
|- cc_blog
What I want to ask is, is it possible to access the blog using aa.com/blog instead of aa.com/aa_blog?
I hope I can access aa.com/blog that pointing to aa_blog without any redirecting, because now I only can access it using aa.com/aa_blog. I tried a lot of changing htaccess method but still not working.
Please for your advice.
Thanks

You need to segregate the Blog Folder from your laravel .htaccess file. Please write the code into your .htaccess file [ laravel ]. Hope it will solve your issue.
RewriteCond $1 !^(blog)
.htaccess file will look like :
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
RewriteCond $1 !^(blog)
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteRule ^(css|js|images)/(.*)$ public/$1/$2 [L,NC]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

Related

Problems to rewrite URL with Laravel, Wordpress and Apache

I have a question / problem with a Laravel project and Wordpress
My Laravel project is multilanguage and the URL is:https://example.com/en/ (look at the /en/)
This project use a blog in Wordpress with this URL https://example.com/en/news
If the directory /en/ exists physically, Apache reads the directory before the friendly path of my project (https://example.com/en is the homepage). The error code is 403, empty directory obviusly.
I tried to move the WordPress installation to another folder like /wordpress/ and rewrite the path of that folder using htaccess but it doesn't work.
I don't know if it's because this doesn't work, or because what I'm trying is impossible
This is the htaccess of the public folder with the Laravel project. I'm using a Plesk server with Apache + Nginx
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
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]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

Apache access to example.com/app from different root directory

For now, I have following directories:
WordPress directory is connected with example.com domain. I would like to access my Zend app by example.com/app URL, but it is in separated directory. I tried to add rewrite rule in htaccess file in WordPress directory, but server responds me with 400 error. I tried that without success:
RewriteRule ^app/(.*)$ ../zend_app/$1
And now I am not sure what to do. I think about some php file to include something from zend_app folder or to create symlink inside WordPress directory pointing to zend_app folder. What solution is better? Maybe there is another solution? I am using shared hosting, so possibilities are limited.
EDIT:
Here is my whole htaccess file from WordPress:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^app/(.*)$ zend_app/$1 [L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

WordPress in root folder and vBulletin in subfolder

I installed WordPress in my host root folder and I installed vBulletin in a subfolder.
I changed my WordPress default permalink to "postname".
Now when I want to open forum (the vBulletin subfolder), it redirects to root folder (WordPress) and gives "not found post".
When I delete .htaccess file in the root folder (WordPress), the subfolder works fine, but accessing WordPress posts gives 404 error.
How can I solve this problem?
It is my WordPress .htaccess file:
# 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
And this is the subfolder (vBulletin) .htaccess file:
# Comment the following line (add '#' at the beginning)
# to disable mod_rewrite functions.
# Please note: you still need to disable the hack in
# the vBSEO control panel to stop url rewrites.
RewriteEngine on
# Some servers require the Rewritebase directive to be
# enabled (remove '#' at the beginning to activate)
# Please note: when enabled, you must include the path
# to your root vB folder (i.e. RewriteBase /forums/)
#RewriteBase /
RewriteCond %{HTTP_HOST} !^soft-game\.ir
RewriteRule (.*) http://soft-game.ir/forums/$1 [L,R=301]
RewriteRule ^((urllist|sitemap_).*\.(xml|txt)(\.gz)?)$ vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 [L]
RewriteCond %{REQUEST_URI} !(admincp/|modcp/|cron|vbseo_sitemap|api\.php)
RewriteRule ^((archive/)?(.*\.php(/.*)?))$ vbseo.php [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !/(admincp|modcp|clientscript|cpstyles|images)/
RewriteRule ^(.+)$ vbseo.php [L,QSA]
You should install wordpress and vBulletin in seperate folders, because a sub-folder in the wordpress insallation means that it is part of wordpress, and it will not act as an unique entity.
Create two folders, name first as 'blogs' or whatever for wordpress and create another folder in the root and name it 'forums' or whatever you like for vBulletin only then the 404 error from wordpress will disappear.

non-wordpress files in wordpress installation directory

I have installed wordpress in root directory. There is a file say test.html in same directory. I can not open this file www.mysiet.com/test.html with this url. When i open this file i get 'No posts found'.(I have coded wordpress's template on my own and this message is in index.php if no posts found). so my questions are:
How can i open an html file that is placed in root directory.
Can i create a new folder in root directory and install another wordpress site in that directory while root directory already have a wordpress installation.
Can i create a new folder in root directory (that already has wordpress installed in it) and place some files in that new directory and access them via my browser.
Thanks
Open your .htaccess in the root folder which once opened should look something like this
# 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`
Then add this above all of that and place your directory in designated spot "replace
with subdirectory name" you can add as many subs as you like
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/REPLACE WITH SUB DIRECTORY NAME/(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^/REPLACE WITH SECOND SUBDIRECTORY NAME/(.*)$ [OR]
RewriteRule ^.*$ - [L]
</IfModule>`
Final Result should look like this if my subdirectory was named other
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/other/(.*)$ [OR]
RewriteRule ^.*$ - [L]
</IfModule>
# 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`
If I understand this you have wordpress installed on your server in its own folder, something like www/wordpress/. You also have a *.html file stored in www/test.html correct?
If I'm on track, then the issue is when you configured this you would have told it to use the wordpress directory. The best solution is to either move that file into the www/wordpress directory or into its own directory off that one, so you could have www/wordpress/test.html or www/wordpress/tests/test.html.
For question 2 I think what you are asking is can you do something like www/wordpress/ having a wordpress site, but then www/wordpress/wordpress2/ having another site. Though this is possible it isn't the best idea, why would you want to do this? You should have www/wordpress/ and www/wordpress2/. If the sites are connected in some way, you should look into wordpress mu, which is a multi site, which will allow you to run many sites all from the same installation.
Question 3 was answered above but yes you can do something like www/wordpress/tests/test.html.
You may need to change your .htaccess rules if you want to be able to access html files under your wordpress install.
You can check for File Permission.

cloaking a folder to show root with wordpress pretty permalinks with htaccess

I installed wordpress in a subdirectory, lets say www.example.com/wordpress. I want the user to hit www.example.com and see the index of www.example.com/wordpress. I'm already using a custom pretty permalinks structure /%category%/%pagename%/ so the htaccess file is a little foreign to me.
My current htaccess file looks 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
AddType x-mapp-php5 .php
AddHandler x-mapp-php5 .php
I've tried numerous solutions from browsing across the web but nothing seems to work. I either get internal 500 errors or view previous pages in the root directory like example.com/about (even though I've deleted the original about.html in the root) even after I deleted my cache.
Any help you could give would be extremely helpful. Thanks for your time,
Rob
The .htaccess file needs to be located in / and not in /wordpress/ and RewriteBase should be / not /wordpress/. Leave the permalinks setup on, but don't use an .htaccess file in /wordpress/. You'll need to set the root directory in your wordpress install to / and setup redirects for /wordpress/wp-content/ and the other wordpress subdirs in /.htaccess so that requests to those directories are also forwarded correctly.
I assume that you want to set up wordpress this way because there are other directories not associated with the wordpress install that you want to be accessible from / (www.example.com/cgi-bin/ for example). You'll need to set up your .htaccess file in / to make any directory aliases (like /cgi-bin/) accessible so requests to /cgi-bin/ don't get redirected to wordpress.
EDIT:
I haven't done something like this in a long time, but here's my best guess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^wp-content/(.*)$ /wordpress/wp-content/$1 [L,QSA]
RewriteRule ^wp-admin/(.*)$ /wordpress/wp-admin/$1 [L,QSA]
RewriteRule ^wp-include/(.*)$ /wordpress/wp-include/$1 [L,QSA]
RewriteCond %{REQUEST_URI} !^/yourAliasUnrelatedToWordpress [NC,OR]
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L,QSA]
</IfModule>

Resources