Printable Version of Topic

Click here to view this topic in its original format

HTMLHelp Forums _ Web Server Configuration _ HTACCESS file merge

Posted by: shondel Oct 10 2016, 12:53 PM

I am developing a php website. I also have wordpress for blog and event calendar plugin capabilities. I recently moved the hatccess and index.php files for wordpress to the root directory so that the permalinks appear to come from the root. My problem is that the new website also has an index.php and htaccess file. I recently renamed the website to home.php and combined the htaccess files and added a DirectoryIndex line for both home.php and index.php. It works in Internet Explorer, but then when I reload a page on Firefox or Chrome, it gives a page not found.

Internet Explorer displays http://www.mydomain.com/#./page
Firefox and Chrome display http://www.mydomain.com/page

Wordpress HTACCESS(on the root):
# 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} ^dancetonightohio.com$
RewriteRule ^/?$ "http\:\/\/www\.dancetonightohio\.com\/" [R=301,L]

New website HTACCESS:
Options +FollowSymLinks +ExecCGI -Indexes

<IfModule mod_rewrite.c>
RewriteEngine On

## uncomment the following line, if you are having trouble
## getting no_script_name to work
#RewriteBase /

## remove trailing slash
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{REQUEST_URI} ^(.+)/$
#RewriteRule ^(.+)/$ $1 [R=301,L]

## turn off index.html, it is for offline mode
RewriteRule ^.*index.html$ index.php [QSA]

## no, so we redirect to our front web controller
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

This is what I combined them as:
DirectoryIndex home.php index.php

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
#RewriteRule ^(.+)/$ $1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

RewriteCond %{HTTP_HOST} ^mydomain.com$
RewriteRule ^/?$ "http\:\/\/www\.mydomain\.com\/" [R=301,L]
# END WordPress

Posted by: Christian J Oct 10 2016, 02:04 PM

QUOTE(shondel @ Oct 10 2016, 07:53 PM) *

It works in Internet Explorer, but then when I reload a page on Firefox or Chrome, it gives a page not found.

.htaccess directives run on the server, so all browsers should get the same result (unless you do browser sniffing in the .htaccess file, which does not appear to be the case).

QUOTE
Internet Explorer displays http://www.mydomain.com/#./page

The part after the # looks like a hashbang, which is normally used together with javascript/Ajax. Maybe some script causes the browser differences.

I don't dare to advice on the actual .htaccess directives, but none of them seem to redirect to the hashbang URL.

Posted by: shondel Oct 13 2016, 12:13 PM

Would anyone know how to properly combine these two htaccess files? Or should my combined file work?

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)