I got a stuck with .htaccess and rewrite - wordpress

I'm using Lamp server on linuxmint and i installed 2 wordpress platforms on it one called "bfsite" and the other one called "titus". I modified the .htacces file as WordPress suggest me to do
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /bfsite/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /bfsite/index.php [L]
</IfModule>
This one is for bfsite, and the I modify for the /titus platform
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /titus/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /titus/index.php [L]
</IfModule>
And a simple redirect.
Redirect /index.php http://89.39.166.81/titus
As you see I made my locahost online for you to see what's happening, when I try to go on
http://89.39.166.81/titus/about
It returns to me with http://localhost/titus/dev/ and also if you force to with this path
http://89.39.166.81/titus/dev/
It comes with a 404 and page not found error, but is going with the "bfsite" wordpress platform.

since you are under a ubuntu distro you can use this
sudo a2enmod rewrite
-- then you can enable postname from wp backend. good luck!

Related

Automatic addition to hdaccess

this code snippet was added to my .htaccess after I installed a plugin.
Is my site viral?
Is this normal?
<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 . /index.php [L]
</IfModule>
Some plugins adds some snippets to the .htaccess specially the security plugins and cache plugins, the one you wrote is the basic WP .htaccess file, so I don't think there would be a problem.

How to enable a WordPress installation and a Mediawiki installation on the same subdomain?

I have a subdomain that has a WordPress installation on its root (e.g. https://sub.domain.com). This opens the WordPress frontpage.
Then I installed a Mediawiki installation in a directory called w, and renamed it using the ShortURL method specified here in this Mediawiki documentation and added the necessary .htaccess adjustments to make the Mediawiki installation uses this url structure: https://sub.domain.com/wiki.
Then I added another Mediawiki installation in another folder called typ and followed the same steps detailed above.
I wanted to have 2 Mediawiki installations for different purposes. They are not linked to each other.
However, after the Mediawiki installations, the WordPress took over, and when I try to access the /wiki urls, I get a 404 not found from the WordPress.
Here is my .htaccess code:
# 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]
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L]
RewriteRule ^/?$ %{DOCUMENT_ROOT}/w/index.php [L]
RewriteRule ^/?typing(/.*)?$ %{DOCUMENT_ROOT}/typ/index.php [L]
RewriteRule ^/?$ %{DOCUMENT_ROOT}/typ/index.php [L]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^/?w/images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/w/thumb.php?f=$1&width=$2 [L,QSA,B]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^/?w/images/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/w/thumb.php?f=$1&width=$2&archived=1 [L,QSA,B]
</IfModule>
# END WordPress
# php -- BEGIN cPanel-generated handler, do not edit
# NOTE this account's php is controlled via FPM and the vhost, this is a place holder.
# Do not edit. This next line is to support the cPanel php wrapper (php_cli).
# AddType application/x-httpd-ea-php70 .php .phtml
# php -- END cPanel-generated handler, do not edit
The only way to get the Mediawiki installations to show is to comment out the WordPress lines, like this:
#RewriteBase /
#RewriteRule ^index\.php$ - [L]
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule . /index.php [L]
My question is: Is there a way to get all the installations working at the same time? so https://sub.domain.com opens the WordPress installation, and https://sub.domain.com/wiki and https://sub.domain.com/typing open the MEdiawiki installation?
The only solution I found is to move the Mediawiki lines up the .htaccess file, remove the duplicates.
Here is the final code that worked:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L]
RewriteRule ^/?typing(/.*)?$ %{DOCUMENT_ROOT}/typ/index.php [L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^/?w/images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/w/thumb.php?f=$1&width=$2 [L,QSA,B]
RewriteRule ^/?w/images/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/w/thumb.php?f=$1&width=$2&archived=1 [L,QSA,B]
RewriteRule ^/?typ/images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/typ/thumb.php?f=$1&width=$2 [L,QSA,B]
RewriteRule ^/?typ/images/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/typ/thumb.php?f=$1&width=$2&archived=1 [L,QSA,B]
</IfModule>

WordPress admin pages redirecting to homepage

i have an issue with WordPress. The site working pretty normal but on the admin panel, various pages like edit post, installed plugins, add new plugin, add new page, settings redirects me to homepage. I'm googling like crazy for 3 days but i just found the mod_security issue. And it turned out useless for me too.
here is my .htaccess file
RewriteEngine On
RewriteBase /
RewriteCond /home/gokkur/public_html/wp-content/sitemaps%{REQUEST_URI} -f
RewriteRule \.xml(\.gz)?$ /wp-content/sitemaps%{REQUEST_URI} [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
SecFilterEngine Off
SecFilterScanPOST Off
this is default content of WP .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
Maybe your custom rewrite rules generating problems.

Wordpress Blog on Subfolder of Ruby on Rails App Hosted on Heroku

I'm having trouble with this. I currently have a wordpress blog on my subdomain, like this: www.blog.websitename.com. However I want to move it to www.websitename.com/blog.
This is where the problem lies because at www.websitename.com, I have a ruby on rails app that's hosted on Heroku. I haven't been able to find any instructions on how to do this.
Would love anyone's suggestions!
In your database you have to serach www.blog.websitename.com and replace it with www.websitename.com/blog.
There is a nice script for this I often use for this purpose:
https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
Download it, upload it into your wordpress folder and call it via webrowser.
Maybe, if you have a .htaccess file in your wordpress folder, you have to adjust the path on 2 lines:
From:
# 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>
To:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>

How to clean url wordpress

I'm using wordpress for a site,
this url before tes.com/index.php/about/
i want url like this tes.com/about/
I have tried copying parts of WordPress' .htaccess, however shows a 404 error.
My .htaccess file looks like:
# 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
Any ideas on where to start and how to accomplish what I'm looking for?
Go to your WP-ADMIN-->Settings-->Permalink and use the permalink structure change there, if it generate any .htaccess file copy the content and update your .htaccess file.
Or Check if your hosting mod_rewrite is enable by creating a file phpinfo.php with content,
Upload this file and browse via Browser. So you know which modules are enabled. You need mod_rewrite enable to remove index.php from URL.
Try this -
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /test.com/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /test.com/index.php [L]
</IfModule>
The official instructions will give you clean urls. So best to follow this
<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 . /index.php [L]
</IfModule>

Resources