Pretty URL's are not working.

Permalink
I am trying the use my .htaccess to stop users and bots from going to urls likehttp://example.com/index.php. I would like to re-write that URL tohttp://example.com. Here is the code I am using in the .htaccess file:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Does anyone have any thoughts on this.

 
ntisithoj replied on at Permalink Reply
ntisithoj
bump...
Sadly, I have the same problem :( I have eh same.htaccess as well, and tried numerous tweaks. I also have issues with Chrome cache, which seems to complicate debugging. I found that firefox private windows are the best... but I still have the problem
cmerritt replied on at Permalink Reply 1 Attachment
cmerritt
This might be a silly question, but have you turned on pretty URLs in dashboard/system/seo/urls ?
ntisithoj replied on at Permalink Reply
ntisithoj
There are so silly questions, only silly answers ;) Yes, and that's always a pain because if the.htaceess is not working, turning on redirs simple breaks every page :/ Then I have to go into /application/config/generated_overrides/concrete.php and edit
'seo' => array(
'url_rewriting' => 0
)

So, same htaccess, pretty URLs on, but http:/site.com/blog = 404 (also set the canonical URL to "http://site.com" and alternative canonical URL to "https://site.com")

I have turned on "LogLevel debug rewrite:trace3" in my vhost config file, but still, when I got to the page http:/site.com/blog and get a 404, and then search all the log files for a rewrite message (cat *|grep 'rewrite' ), I get nothing... so it kinda looks like the rewrite is being totally ignored. The module is reported as loaded in the apache config.

I moved the rules to the vhost config file as well, but no difference

.htaccess is globally readable, and the vhost has "AllowOverride All"

To test, I changed my rules to simply
RewriteEngine On
RewriteRule ^(.*)$ http://google.com/ [R=301,L]


And, indeed, the rewrite logs show the following

[Sat Feb 09 14:53:00.162875 2019] [rewrite:trace1] [pid 21373]
mod_rewrite.c(483): [client 127.0.0.1:37794] 127.0.0.1 - -
[site.com/sid#561e73ad6c18][rid#561e73c91a00/initial] [perdir
/store/jw/sites/site.com/] redirect to
http://google.com/?uid=5c5f137c27a0d&tags=product&api=1&path=/products&longtitle=products
[REDIRECT/301]


BUT, the webpage does not go to google.com... it goes to the site.com page !? It seems to be completely ignoring the redirect.

Then, I turned on the C5 .htaccess, and I get no redirect log messages at all... redirection is being completely ignored. This is the case for bothhttp://site.com/index.php/blah andhttp://site.com/blah

So, at this point I am at a total loss.

I am running Apache/2.4.38
ConcreteOwl replied on at Permalink Reply
ConcreteOwl
Redacted
ntisithoj replied on at Permalink Reply
ntisithoj
Followup... it seems that the redirection I was seeing was NOT for the webpage I was entering, but for an ajax call within the webpage. When I removed the ajax call no redir messages showed up in the logs. So, the webpages (http://site.com/index.php//blah orhttp://site.com/blah) are being ignored, but the ajax call for the same site (http://site.com//bin/tmaker.php) is not.
ntisithoj replied on at Permalink Reply
ntisithoj
ok, try this. It worked for me.

Do not use the .htacess file at all for redirects. Not idea why, but on (my) Apache 2.4 it seems to be ignored :/

Put the same lines in your vhost config file, making sure it is inside the <Directory> block, otherwise the paths will be absolute, not relative. p.s. everything in a .htacccess file is assumed to be in a <Directory> block.

This is what my vhost config now looks like

<VirtualHost *:80>
        ServerName site.com
        ServerAlias www.site.com
        DocumentRoot /store/jw/sites/site.com/
        #RewriteOptions Inherit # only use if applying rule to proxies
        <Directory  /store/jw/sites/site.com/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
                Require all granted
                LogLevel debug rewrite:trace5
                RewriteEngine On
                RewriteBase /
                RewriteCond %{REQUEST_FILENAME} !-f
ally2112 replied on at Permalink Reply
ally2112
Thanks for your thorough investigation! this saved me time and headaches!
goimagemedia replied on at Permalink Reply
If you are running a Windows server for local development, you will in all likelihood need to modify the httpd.conf file found in the directory /conf
In the distribution I'm using, the required changes to enable .htaccess

Enable these two modules
LoadModule headers_module modules/mod_headers.so
LoadModule rewrite_module modules/mod_rewrite.so

Look for something like

<Directory ></Directory>
AllowOverride None (change this to AllowOverride All)
Require all denied
</Directory>

Look for something like
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride None (change this to AllowOverride All)