php - How to put a trailing slash from a mod rewrite -
i'm having problem using rewrite:
rewritecond %{http_host} www.example.com$ rewriterule ^(.*)$ http://example.com$1 [r=301,l] to remove www url
but return url without trailing slash. example: example.com/subfolder supposedly has url of example.com/subfolder, result example.comsubfolder whch breaks url. me solving this? many thanks!
edit: here's whole .htaccess
header unset pragma fileetag none header unset etag # 1 year <filesmatch "\.(ico|pdf|flv)$"> header set cache-control "max-age=29030400, public" </filesmatch> # 1 week <filesmatch "\.(jpg|jpeg|png|gif|swf)$"> header set cache-control "max-age=604800, public" </filesmatch> # 2 days 172800 <filesmatch "\.(xml|txt|css|js)$"> header set cache-control "max-age=604800, proxy-revalidate" </filesmatch> # 1 min <filesmatch "\.(html|htm)$"> header set cache-control "max-age=60, private, proxy-revalidate" </filesmatch> <filesmatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$"> header set expires "thu, 15 dec 2011 20:00:00 gmt" </filesmatch> rewriteengine on rewritecond %{query_string} (^|\?)f=([0-9]+)&t=([0-9]+)($|&) rewriterule ^viewtopic\.php$ /index.php?threads/%3/ [r=301,l] rewritecond %{query_string} (^|\?)f=([0-9]+)($|&) rewriterule ^viewforum\.php$ /index.php?forums/%2/ [r=301,l] rewritecond %{http_host} www.example.com$ rewriterule ^(.*)$ http://example.com/$1 [r=301,l] # use php5.4 single php.ini default addhandler application/x-httpd-php54s .php # # uncomment statement below if want make use of # http authentication , not work. # required if example using php via apache cgi. # ## expires caching ## <ifmodule mod_expires.c> # enable expirations expiresactive on # default directive expiresdefault "access plus 1 month" # favicon expiresbytype image/x-icon "access plus 1 year†# images expiresbytype image/gif "access plus 1 month" expiresbytype image/png "access plus 1 month" expiresbytype image/jpg "access plus 1 month" expiresbytype image/jpeg "access plus 1 month" # css expiresbytype text/css "access 1 month†# javascript expiresbytype application/javascript "access plus 1 year" </ifmodule> ## expires caching ## #<ifmodule mod_rewrite.c> #rewriteengine on #rewriterule .* - [e=http_authorization:%{http:authorization},l] #</ifmodule> <files "config.php"> order allow,deny deny </files> <files "common.php"> order allow,deny deny </files> directoryindex portal.php index.php index.html index.htm rewritecond %{http_referer} !^http://example.com/.*$ [nc] rewritecond %{http_referer} !^http://example.com$ [nc] rewritecond %{http_referer} !^http://www.example.com/.*$ [nc] rewritecond %{http_referer} !^http://www.example.com$ [nc] rewriterule .*\.(jpg|jpeg|gif|png|bmp)$ - [f,nc] # start cloudflare:example.com rewrite. not edit rewritecond %{http_host} ^example.com rewriterule ^(.*)$ http://www.%{http_host}/$1 [r=301,l] # end cloudflare rewrite. # mod_security can interfere uploading of content such attachments. if # cannot attach files, remove "#" lines below. #<ifmodule mod_security.c> # secfilterengine off # secfilterscanpost off #</ifmodule> errordocument 401 default errordocument 403 default errordocument 404 default errordocument 405 default errordocument 406 default errordocument 500 default errordocument 501 default errordocument 503 default <ifmodule mod_rewrite.c> # if having problems rewrite rules, remove "#" # line begins "rewritebase" below. have change path # line may needed enable webdav editing php cgi. #rewriterule .* - [e=http_authorization:%{http:authorization}] rewritecond %{request_filename} -f [or] rewritecond %{request_filename} -l [or] rewritecond %{request_filename} -d rewriterule ^.*$ - [nc,l] rewriterule ^(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt) - [nc,l] rewriterule ^.*$ index.php [nc,l] </ifmodule>
Comments
Post a Comment