Friendly url on pagination url? - .htaccess

I have this
http://localhost/index.php?page=1
And I want show this
http://localhost/index.php/page/1
I have now on .htaccess this code:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^index/([0-9]+)$ index.php?page=$1
But this not work, please help me.

You are missing your script extension an page part
RewriteRule ^index.php/page/([0-9]+)$ index.php?page=$1

Related

Error on SEO friendly url

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^([a-zA-Z0-9-]+)/?$ listenAlbum.php?url=$1
RewriteRule ^([a-zA-Z0-9-]+)/category/?$ category.php?name=$1
I am having this .htaccess file
when i try to open http://mywebsite.com/my-album it works perfect
but when i try to navigate on category page like this
http://mywebsite.com/category/category-name it give a 404 Not Found
Can any one help with this ?
The second RewriteRule if your htaccess says the URL should be http://mywebsite.com/category-name/category/.
Change your htaccess to:
RewriteEngine On
RewriteRule ^([a-zA-Z0-9-]+)/?$ listenAlbum.php?url=$1
RewriteRule ^category/([a-zA-Z0-9-]+)/?$ category.php?name=$1

URL Rewrite Rule shows blank page with text

i'm learning how to rewrite urls and im trying to do that in my ubuntu server. I managed myselft to activate the Allowoverride All and i have htacess working.
I want to change this url for example:
http://serverismai/myapi/public/rest/navigate.php
And i try to do it like this :
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^home(.*)$ myapi/public/rest/curso/navigate.php/$1 [L]
</IfModule>
I've tried various solutions but this was the closest i got. The url dosent change automatically but if i insert http://serverismai/myapi/public/rest/home i see a blank page with some of my website html written ( not even the html of the page i'm trying to rewite url).
I'm pretty new to this so i want to know if there is something wrong in the Rewrite Rule or if my error is somewhere else...
Thank you!
You can use this code in your /myapi/public/rest/.htaccess file:
RewriteEngine On
RewriteBase /myapi/public/rest/
RewriteRule ^home/?$ curso/navigate.php [L,NC]

How to change specific page slug with .HTACCESS?

I got a website script where it's very difficult to change page slugs.
So I thought I can do this with .htaccess.
I got my page url like - www.mysite.com/submit
So can I change this with .htaccess to www.mysite.com/create ???
Thank you!
Something as simple as your example can be easily done by .htaccess. Use this code in .htaccess under DOCUMENT_ROOT:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^submit/?$ create [L,NC,R]
RewriteRule ^create\$ /submit [L]
or
RewriteRule ^create$ /submit [L]

mod_rewrite 301 redirect not working

I'm trying to set up a rewrite that will redirect this URL:
/video-2011.php?video=150
to this:
/video/150/freeform-title-text-here/
I have the rewrite working using this line in my HTACCESS:
RewriteRule ^video/([0-9]+)/(.*)$ video-2011.php?video=$1 [L]
But as soon I add R=301 into the mix, it breaks. Any ideas?
Here's the full HTACCESS when it breaks:
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule ^video/([0-9]+)/(.*)$ video-2011.php?video=$1 [R=301,L]
Any help is greatly appreciated, thanks!
I think you might be missing a line from your .Htaccess.
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule ^video/([0-9]+)/([a-z0-9-_]+)$ video-2011.php?video=$1 [L]
#New
RewriteCond %{REQUEST_URI} !^/video/([0-9]+)/([a-z0-9-_]+)/?$
RewriteCond %{QUERY_STRING} ^video=([0-9]+)&name=([a-z0-9-_]+)/?$
RewriteRule ^video-2011.php$ video/%1/%2/? [R=301,L]
I assuming you want to rewrite the url if it is:
/video/150/freeform-title-text-here/
And redirect the url if it is:
/video-2011.php?video=150
to:
/video/150/freeform-title-text-here/
So this way it keeps the urls looking pretty and tidy.
Please correct me if I am wrong.
Edit
I've added in a RewriteCond to stop the second rewrite happening.
As the first rule will obviously rewrite:
/video/150/freeform-title-text-here/
Which means the query string you don't see:
/video-2011.php?video=150
Would of made the second rule happen too.
Can you try:
RewriteRule ^video/([0-9]+)/ /video-2011.php?video=$1 [R=301,L,NC,QSA]
And yes it will redirect /video/150/foo to /video.php?video=150 not the other way around as you've stated in your question.

URL rewriting using htaccess

How to rewrite the url in htaccess
www.mywebsite.com/category.php?name="richard" change to www.mywebsite.com/richard/
You can use below code to achieve your requirement.
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{QUERY_STRING} name=(.*)
RewriteRule category\.php$ /%1/
Hope this helps you... :)
Are you used any PHP frameworks(like the codenigter... etc)?
You can try this:
RewriteRule ^(.*)$ /category.php/name=$1 [L]

Resources