Forum Moderators: phranque
RewriteEngine On#untuk url dengan pola www.example.com/page/about-us atau www.example.com/page/about-us/sub-about-us
RewriteRule ^page/(.*)\/(.*)\/? /index.php?page=$1&subpage=$2 [NC]#404 page
ErrorDocument 403 /index.php?page=404
ErrorDocument 404 /index.php?page=404RewriteCond %{REQUEST_URI} !^/(index.php).* [NC]
RewriteCond %{THE_REQUEST} !^[A-Z]{3,9}\ [a-zA-Z0-9\.\+_/\-\?\=\&]+\ HTTP/ [NC]
RewriteRule .* - [F,NS,L]
And this is my real URL
http://example.com/index.php?page=about-us&subpage=full-story
With .htaccess above, my url turn to
http://example.com/page/about-us/full-story
But when access http://example.com/page/about-us , it will return 404 pages, bcause doesnt have backslash .. so how to give automatic backslash when user access http://example.com/page/about-us => http://example.com/page/about-us/
Please note, i've try this code to add backslash automatic
# If the url is not an existing directory
#RewriteCond %{REQUEST_FILENAME} !-d
# and the URI does not contain a full stop (Example: index.html)
#RewriteCond %{REQUEST_URI} !\.
# and if the URI does not end with a slash
RewriteCond %{REQUEST_URI} !/$
# Rewrite the URI to have a trailing slash
RewriteRule (.+) /$1/ [R=301,L]
It's ok, but when access subpage, everything as broken :(
need help to resolve this :)
thnx b4 and regards
[edited by: engine at 8:46 am (utc) on Oct. 24, 2009]
[edit reason] Please use example.com [/edit]
So all I can suggest is that you clean up this code and see if it helps:
# Declare custom error documents
ErrorDocument 403 /index.php?page=404
ErrorDocument 404 /index.php?page=404
#
# Enable mod_rewrite rewriting engine
RewriteEngine on
#
# Allow only the listed characters in requested URL-paths
RewriteCond %{THE_REQUEST} !^[A-Z]{3,9}\ /[a-zA-Z0-9.+_/?=&\-]*\ HTTP/
RewriteRule !index\.php$ - [NS,F]
#
# Internally rewrite /page/<page>/<subpage> to /index.php/page=<page>&subpage=<subpage>
RewriteRule ^page/([^/]+)/([^/]+)/?$ /index.php?page=$1&subpage=$2 [NC,L]