If i type a url without .html extenstion the page shows blank.
If i type a url without .html extenstion the page shows blank.
Hi I have just put my site live and I cant for life of me get the url rewrite to work properly. I need to get a 404 page working for urls typed in without .html extension idealy to redirect to home page
My problem is that if you type in www.mysite.com/hello.html it returns 404 because the page doesnt exist
if you type in www.mysite.com/hello it returns a blank page.
Hope someone can help.
Htaccess file is:
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]
# Rewrites urls in the form of /parent/child/
# but only rewrites if the requested URL is not a file or directory
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteRule ^(.+)$ /index.php?page=$1 [QSA]
config.php:
$config['assume_mod_rewrite'] = true;
$config['page_extension'] = '.html'; (I have tried this as:$config['page_extension'] = ''; )
$config['internal_pretty_urls'] = false;
$config['use_hierarchy'] = true;
I have tried both versions of the htaccess in the pretty urls instructions but both return blank pages.
Another problem is that I can not get a cutom error page to work.
I had created "error 404" page in admin and added
#404 redirect
ErrorDocument 404 /error-404.html
but it doesnt work. It always goes to server default 404
if you use custom 404 in admin this works. it must all be related to the htaccess file
Thanks,
My problem is that if you type in www.mysite.com/hello.html it returns 404 because the page doesnt exist
if you type in www.mysite.com/hello it returns a blank page.
Hope someone can help.
Htaccess file is:
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]
# Rewrites urls in the form of /parent/child/
# but only rewrites if the requested URL is not a file or directory
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteRule ^(.+)$ /index.php?page=$1 [QSA]
config.php:
$config['assume_mod_rewrite'] = true;
$config['page_extension'] = '.html'; (I have tried this as:$config['page_extension'] = ''; )
$config['internal_pretty_urls'] = false;
$config['use_hierarchy'] = true;
I have tried both versions of the htaccess in the pretty urls instructions but both return blank pages.
Another problem is that I can not get a cutom error page to work.
I had created "error 404" page in admin and added
#404 redirect
ErrorDocument 404 /error-404.html
but it doesnt work. It always goes to server default 404
if you use custom 404 in admin this works. it must all be related to the htaccess file
Thanks,
-
- Forum Members
- Posts: 116
- Joined: Mon Jul 28, 2008 4:48 pm
- Location: Cambridge, UK
Re: If i type a url without .html extenstion the page shows blank.
I'd just take your 404 handling out of the htaccess and use the options on the Site Admin / Global Settings page in admin.
Nick
Nick
Re: If i type a url without .html extenstion the page shows blank.
Ihave tried that one but it doesnt work with pages typed in without the .html on the end
if you type a url in that doesnt exist but put the html on the end it returns the 404 page set in admin.
No one is ever going to misstype a url and then put the html exstension on the end of it.
I cant figure out the htaccess to get it right
if you type a url in that doesnt exist but put the html on the end it returns the 404 page set in admin.
No one is ever going to misstype a url and then put the html exstension on the end of it.
I cant figure out the htaccess to get it right
Last edited by Gally on Tue Sep 09, 2008 1:40 pm, edited 1 time in total.
-
- Forum Members
- Posts: 116
- Joined: Mon Jul 28, 2008 4:48 pm
- Location: Cambridge, UK
Re: If i type a url without .html extenstion the page shows blank.
It works fine for me - I use mod_rewrite with the same settings you have and invalid pages with or without the .html ending return the 404 message as set on the Global Settings page.
However.... I have realised that it doesn't behave without the .html extension on a site I have running on MLE. Not sure if that is to do with the language code in the url. I need to investigate further.
Nick
However.... I have realised that it doesn't behave without the .html extension on a site I have running on MLE. Not sure if that is to do with the language code in the url. I need to investigate further.
Nick
Re: If i type a url without .html extenstion the page shows blank.
Thanks.
If i change $config['page_extension'] = '.html'; to $config['page_extension'] = '/'; then pages work without .html
but you can not get an error page unless you put a / on the end
ie www.mysite.com/ugugugug/ returns a 404
www.mysite.com/ugugugug returns a blank page
so is the problem the config.php or htacess. Its the fact that it always wants to see someting on the end of the url.
If i change $config['page_extension'] = '.html'; to $config['page_extension'] = '/'; then pages work without .html
but you can not get an error page unless you put a / on the end
ie www.mysite.com/ugugugug/ returns a 404
www.mysite.com/ugugugug returns a blank page
so is the problem the config.php or htacess. Its the fact that it always wants to see someting on the end of the url.
-
- Forum Members
- Posts: 116
- Joined: Mon Jul 28, 2008 4:48 pm
- Location: Cambridge, UK
Re: If i type a url without .html extenstion the page shows blank.
Well I managed to get my 404 page working on my MLE site. I added a couple of extra lines to my htaccess file to default the language to English (en), i.e.
Anyway, I would try removing all this from your htaccess:
Put everything else back the way it was in your original post and use the 404 handling in the Global Settings page.
Nick
Code: Select all
RewriteRule ^(.*).html$ /index.php?hl=en&page=$1
RewriteRule ^(.*).htm$ /index.php?hl=en&page=$1
Code: Select all
# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]
Nick
Last edited by Anonymous on Tue Sep 09, 2008 4:28 pm, edited 1 time in total.
Re: If i type a url without .html extenstion the page shows blank.
Thanks for your help on this one, but still no luck.
when you miss type a url, as long as it has a / or .html on the end it will return the custom 404 page.
If you leave the url open ended it will return a blank screen.
I dont understand enough about the config file or php to know why it needs to see an extension.
when you miss type a url, as long as it has a / or .html on the end it will return the custom 404 page.
If you leave the url open ended it will return a blank screen.
I dont understand enough about the config file or php to know why it needs to see an extension.
Re: If i type a url without .html extenstion the page shows blank.
It doesn't need an ext. but / at the end is going to frustrate search engines as that is a standard call for a folder so they may think there is a folder to open not find it and get confused...
I highly recommend against / at the end...
I highly recommend against / at the end...
Re: If i type a url without .html extenstion the page shows blank.
I think you miss read what the problem is.
I want the custom 404 page to display if you miss type a url Example. www.mysite.com/jjgjgjgjgjg This url will return a blank page.
If you type www.mysite.com/jjgjgjgjgjg/ or www.mysite.com/jjgjgjgjgjg.html it returns the custom 404 page
The problm is you are never going to miss type a url and then put / or html on the end.
I cant figure out why cmsms always wants to see an exstention on the end of the url.
I have tried the html and non html versions of htaccess but it is still the same
I want the custom 404 page to display if you miss type a url Example. www.mysite.com/jjgjgjgjgjg This url will return a blank page.
If you type www.mysite.com/jjgjgjgjgjg/ or www.mysite.com/jjgjgjgjgjg.html it returns the custom 404 page
The problm is you are never going to miss type a url and then put / or html on the end.
I cant figure out why cmsms always wants to see an exstention on the end of the url.
I have tried the html and non html versions of htaccess but it is still the same
-
- Forum Members
- Posts: 116
- Joined: Mon Jul 28, 2008 4:48 pm
- Location: Cambridge, UK
Re: If i type a url without .html extenstion the page shows blank.
I don't know what else to suggest. The 404 error trapping works the way you would like it to on my sites.
Just to recap, my entire htaccess file consists of:
I use the 404 handling in Global Settings and these options set in my config.php:
I don't have any other 404 files on the server or 404 handling set in the server control panel.
Maybe someone else has some other suggestions.
Nick
Just to recap, my entire htaccess file consists of:
Code: Select all
# Rewrite the URLs
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*).html$ /index.php?page=$1
RewriteRule ^(.*).htm$ /index.php?page=$1
# Turns off directory browsing
# not absolutely essential, but keeps people from snooping around without
# needing empty index.html files everywhere
Options -Indexes
# Deny access to config.php
# This can be useful if php ever breaks or dies
# Use with caution, this may break other functions of CMSms that use a config.php
# file. This may also break other programs you have running under your CMSms
# install that use config.php. You may need to add another .htaccess file to those
# directories to specifically allow config.php.
<Files "config.php">
order allow,deny
deny from all
</Files>
# No sense advertising what we are running
ServerSignature Off
Code: Select all
#------------
#URL Settings
#------------
#Show mod_rewrite URLs in the menu? You must enable 'use_hierarchy' for this to work for modules
$config['assume_mod_rewrite'] = true;
#Extension to use if you're using mod_rewrite for pretty URLs.
$config['page_extension'] = '.html';
#If you don't use mod_rewrite, then would you like to use the built-in
#pretty url mechanism? This will not work with IIS and the {metadata} tag
#should be in all of your templates before enabling.
$config['internal_pretty_urls'] = false;
#If you're using the internal pretty url mechanism or mod_rewrite, would you like to
#show urls in their hierarchy? (ex. http://www.mysite.com/parent/parent/childpage)
$config['use_hierarchy'] = true;
#If using none of the above options, what should we be using for the query string
#variable? (ex. http://www.mysite.com/index.php?page=somecontent)
$config['query_var'] = 'page';
Maybe someone else has some other suggestions.
Nick