I have successfully implemented pagination in a drupal 8 view block.
Now it generates the following URL for me :
http://tommiecrawford.local/node?page=1
But i don't want this.
I want to have the following urls for my pagination links.
http://tommiecrawford.local/blog/page/1
http://tommiecrawford.local/blog/page/2
http://tommiecrawford.local/blog/page/3
etc..
I already tried this with htaccess but it's not working with the following config :
RewriteCond %{THE_REQUEST} page=$
RewriteRule . http://tommiecrawford.local/blog/page/$1 [R=301,L]
Is there a module or a fix for this?
Thanks.
You can use:
RewriteEngine on
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} \s/+node\?page=([^\s&]+) [NC]
RewriteRule ^ /blog/page/%1? [R=302,L,NE]
# internal forward from pretty URL to actual one
RewriteRule ^blog/page/(.+?)/?$ /node?page=$1 [L,QSA,NC]
Related
I want to make example.com /productName to example.com /product/productName
I just want to add static text /product/ in mid to url how can i add this with .htaccess file to url structure? I already tried this code but it did not worked.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
#hiding parameter name and product.php
RewriteRule ^([^\.]+)$ /product.php?productName=$1 [NC,L]
With your shown attempts, please try following htaccess Rules. Please make sure to keep your htaccess along with folder product(not inside product folder).
Make sure to clear your browser cache before testing your URLs.
##Making rewrite engine on
RewriteEngine ON
##rules for external redirect
RewriteCond %{THE_REQUEST} \s/(product)\.php\?code=(\S+)\s [NC]
RewriteRule ^ /%1/%2? [R=301,L]
##Rules for internal rewrite here.
RewriteRule ^(product)/(.*)/?$ $1.php?code=$2 [QSA,L,NC]
I would like to make a rewrite rule for my website but I cannot seem to get the proper code in order to make this work.
The current URL of my website is looking like http://www.mohanadarafe.io/JSON/json.html
I want it to be: http://www.mohanadarafe.io/json
I have tried the following code but it does not seem to work:
RewriteEngine On
RewriteRule ^\.html$ /json [L]
Any idea how to fix this?
You have it reversed. Have it like this:
RewriteEngine On
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} /JSON/json\.html [NC]
RewriteRule ^ /json [R=301,L]
# internal forward from pretty URL to actual one
RewriteRule ^json/?$ JSON/json.html [L,NC]
Then you can have your URL as: http://www.mohanadarafe.io/json
Currently, my site has this url format:
https://example.com/blog/news.php?read=article-title-here
I would like to change this url to:
https://example.com/news/article-title-here
Any idea how to do this please? I tried this method but see no changes in the browser bar(even after emptying the cache):
RewriteCond %{QUERY_STRING} ^read=(.*)$
RewriteRule ^news/?$ %1.php? [R=301,L]
Also, where should the htaccess file be written?
in https://example.com/
or
https://example.com/blog/
Thank you in advance!
Ben
You can use in your https://example.com/.htaccess:
Options -MultiViews
RewriteEngine on
RewriteBase /
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} \s/+blog/news\.php\?read=([^\s&]+) [NC]
RewriteRule ^ /news/%1? [R=301,L,NE]
# internal forward from pretty URL to actual one
RewriteRule ^news/(.+?)/?$ blog/news.php?read=$1 [L,QSA,NC]
here i am trying to rewrite url but its not working
> Options +FollowSymlinks RewriteEngine on rewriterule
> ^FAQ.php?view=why_best(.*)$ http://www.bestsports.ca/FAQ/WhyBest$1
> [r=301,nc]
old url is http://www.bestsports.ca/FAQ.php?view=why_best
New Url http://www.bestsports.ca/FAQ/WhyBest should be like this
after editing htacces fiel its opening the same old url please help
thanks
i am trying this code now
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{THE_REQUEST} \s/+FAQ\.php\?view=why_best [NC]
RewriteRule ^ /FAQ/WhyBest/? [R=301,L]
RewriteRule ^FAQ/WhyBest/?$ /FAQ.php?view=why_best [QSA,NC,L]
RewriteRule ^ /FAQ/SizeChart/? [R=301,L]
RewriteRule ^FAQ/SizeChart/?$ /FAQ.php?view=size_chart [QSA,NC,L]
but its showing error
The page isn't redirecting properly
and if i click same link again for FAQ.php?view=why_best its
redirected to
http://www.bestsports.ca/FAQ/WhyBest/FAQ.php?view=why_best
as you helped me i completed the above seo url rewrite problem for my all other website pages
i used the third party cart system from ecwid when i click on any proudct its show this link or url
http://www.bestsports.ca/product.php#!/~/product/category=9414048&id=11484861
how can i rewrite this url insted of showing category id and i want to show name
i already tried your above instruction but its not working can you please explain is it possible to make this url seo friendly url
thank you
You cannot match query string in RewriteRule. Use RewriteCond instead:
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{THE_REQUEST} \s/+FAQ\.php\?view=why_best [NC]
RewriteRule ^ /FAQ/WhyBest? [R=301,L]
RewriteRule ^FAQ/WhyBest/?$ /FAQ.php?view=why_best [QSA,NC,L]
My site is: http://binodgiri.com.np, when you click on link you are redirecte to: http://www.binodgiri.com/what.php?id=1
I want to display above url as
http://www.binodgiri.com.np/change-url/
I tried following on .htaccess file
RewriteEngine On
RewriteRule ^change-url/(.*)$ what.php?id=1 [L]
(I don't have much knowledge on this stuff.)
Try this, it should redirect http://www.binodgiri.com/what.php?id=1 to http://www.binodgiri.com.np/change-url/
RewriteCond %{THE_REQUEST} ^(GET|POST)\ /what\.php\?id=1\ HTTP
RewriteRule ^ /change-url\? [R,L]