Guest xvids Posted April 28, 2017 Posted April 28, 2017 Hello,,, How I can browse a page without slash Adding or removing a trailing slash to all URLs of this site returns an error page (404). This is OK as no content is being duplicated, but visitors might try browsing to the pages of this website with or without a trailing slash. Ideally, the alternate URL should redirect to the correct page. LIKE: https://www.xvids.cc/video/amateur-t...ies-best-ever/ https://www.xvids.cc/video/amateur-t...cies-best-ever https://www.xvids.cc/latest-updates/ https://www.xvids.cc/latest-updates RewriteRule ^videos/([0-9]+)/([^/]+)/$ /view_video.php?id=$1&dir=$2 [L,QSA] RewriteRule ^videos/([^/]+)/$ /view_video.php?dir=$1 [L,QSA] RewriteRule ^latest-updates/([0-9]+)/$ /videos_list_latest.php?from=$1 [L,QSA] RewriteRule ^latest-updates/$ /videos_list_latest.php [L,QSA] RewriteRule ^top-rated/([0-9]+)/$ /videos_list.php?sort_by=rating&from=$1 [L,QSA] RewriteRule ^top-rated/$ /videos_list.php?sort_by=rating [L,QSA] RewriteRule ^most-popular/([0-9]+)/$ /videos_list.php?sort_by=video_viewed&from=$1 [L,QSA] RewriteRule ^most-popular/$ /videos_list.php?sort_by=video_viewed [L,QSA] RewriteRule ^categories/([0-9]+)/$ /categories_videos.php?from=$1 [L,QSA] RewriteRule ^categories/$ /categories_videos.php [L,QSA] RewriteRule ^categories/([^/]+)/([0-9]+)/$ /videos_list.php?category=$1&from=$2 [L,QSA] RewriteRule ^categories/([^/]+)/$ /videos_list.php?category=$1 [L,QSA] Thanks Quote
Tech Support Posted May 1, 2017 Posted May 1, 2017 The only good way I know is to duplicate each rule with 301 redirect. Sample rules: RewriteRule ^latest-updates/([0-9]+)/$ /videos_list_latest.php?from=$1 [L,QSA] RewriteRule ^latest-updates/$ /videos_list_latest.php [L,QSA] Add redirect rules without / at the end: RewriteRule ^latest-updates/([0-9]+)$ /latest-updates/$1/ [R=301,L] RewriteRule ^latest-updates$ /latest-updates/ [R=301,L] This should redirect: http://domain.com/latest-updates -> 301 -> http://domain.com/latest-updates/ http://domain.com/latest-updates/2 -> 301 -> http://domain.com/latest-updates/2/ http://domain.com/latest-updates/3 -> 301 -> http://domain.com/latest-updates/3/ etc. I have also seen some generic redirects, which were claimed to redirect all URLs automatically, however they should also consider filenames and do not force redirect for files. This is dangerous practice, as it can lead to some functionality not working. You can find those in google: https://www.google.com/search?q=mod_rewrite+add+trailing+slash+to+all+url s My opinion is better not to use it. Quote
xvids Posted May 1, 2017 Posted May 1, 2017 Hi I had created a ticket for about this question Answer is: Just the ? But where adding this ? I don't know More example: this is facebook page If I Type https://www.facebook.com/4XVIDS OR https://www.facebook.com/4XVIDS/ Both URL working Without / Quote
Tech Support Posted May 2, 2017 Posted May 2, 2017 xvids: sorry, your first account was removed by mistake when cleaning spammer accounts. I had created a ticket for about this question Do you mean you have created support ticket now? We do not see any ticket from you... If you want to make both URLs accessible without 301 redirect, then it is even easier, you can add ? at the end of every rule which ends with /. Example: RewriteRule ^latest-updates/([0-9]+)/$ /videos_list_latest.php?from=$1 [L,QSA] RewriteRule ^latest-updates/$ /videos_list_latest.php [L,QSA] Changed: RewriteRule ^latest-updates/([0-9]+)/?$ /videos_list_latest.php?from=$1 [L,QSA] RewriteRule ^latest-updates/?$ /videos_list_latest.php [L,QSA] You can find such places by searching for /$ - almost every rule in .htaccess ends with that. So you can batch replace with /?$ But please make a backup of .htaccess before applying batch replace to it. This will mean that both will work: http://domain.com/latest-updates/ http://domain.com/latest-updates The only possible issue is content duplication, however by default theme should display canonical URL for every page, so there won't be duplication. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.