I am trying to rewrite my url for generating the seo friendly url. My original url is something like
video_play.php?cat=1?author=3?video=4
where
"cat=1" is represents my category and 1 is id of my category name like song,movie etc..
"author=3" 3 is the id of singer.
"video=4" 4 is the id of track being played currently...
I want to make this url some thing like video_play/song/artistname/songtitle.html
I am trying this code in .htaccess if any one can help me.. Thanks in advance...
RewriteRule /author/(.*)/cate/(.*) video_play.php?author=$1&cate=$2
Try this instead:
RewriteRule /author/([^\.]*)/cate/([^\.]*) video_play.php?author=$1&cate=$2
Related
How to create an SEO friendly URL like example.com/pages/my-first-page/followers here I want how to create a structure in if(isset($_GET['followers'])){...} and htaccess file.
My link working fine till example.com/pages/my-first-page/ but now I want to add followers section.
I hope i explain well what I expecting. Thanks for your help
Rule you've suggested is this:
RewriteRule ^pages/([\w-]+)/followers/?$ page.php?pages=$1&followers=1 [QSA,NC,L]
This is pretty good rule and there is no reason why it should not work. Make sure this rule is placed before page rule which is your first rule in .htaccess
Is there the opportunity to get content on one url from another url? like this:
test.com/dir1 shows content from query test.com/getinfo/index.php?q=dir1
or
test.com/dir2 shows content from query test.com/getinfo.php?q=dir2
I need that because i must do 50 urls like test.com/dir1 ../dir50 which has the same template but with some different content based on query and one virtual url with query is better than 50 real directories.
I tried do but couldnt! Thanks in advance!
If it is all on the same host, then have a look at mod_rewrite, which can do amazing things. Just make sure you read the manual through, as there are a lot of details to take in.
RewriteEngine On
RewriteRule ^/dir1$ /getinfo/index.php?q=dir1 [L]
or more generically:
RewriteEngine On
RewriteRule ^/dir(.*)$ /getinfo/index.php?q=dir$1 [L]
I am upgrading my site which involves new scripts and a different URL
structure. There are currently a few thousand pages so I want to
basically move them in to a subdirectory so that they are not lost.
I am not very confident with htaccess so can someone please confirm that
the first part I have done is correct:
Old URL: http://www.example.com/article/another-dir/page-group/whatever.html
RewriteRule ^article/?$ http://www.example.com/archive/ [R=301,NC,L]
To achieve this: http://www.example.com/archive/another-dir/page-group/whatever.html
Search engines will see the above as a permanent move and in the address bar
it will show the new url. Is this right?
The second part is on the new script - the url's could be improved but I am
unable to change all the script so thought about using htaccess again but am
not sure if it can be achieved like this.
At the moment the url looks like this:
url: http://www.example.com/category/4/categoryname
In the htaccess the current rewrite rule for this type of url looks like this:
RewriteRule ^category/(.*)/(.*)$ category.php?id=$1&slug=$2
Is it possible to change this so that in the url address bar I end up
with this:
http://www.example.com/categoryname
Basically I don't want to see either the number or category/ in the resulting
url as it will be easier for visitors to use - is that possible??
Thanks in advance for any help.
The second question related to passing in URI components for querystring redirect and then hiding those components in the URL I don't think would be easy, if even possible, using RewriteRules.
For the first question though. Given the sample URLs you mentioned, the RewriteRule would need to include capture and backreference if you want to preserve the full URL in the redirection. For example:
RewriteRule ^article/?(.*)$ http://www.example.com/archive/$1 [R=301,NC,L]
I'm developing a new website and want to make URLs SEO friendly.
My RewriteRule in .htaccess:
Working: RewriteRule ^news/design-watches/(.*)/(.*)/(.*)\.html$ news_view.php?category=$1&title=$2&id=$3
Return: http://localhost/news/design-watches/Technical-Data/Test-News-9/37.html
Question:
Is it possible to hide ID from URL and still sending an variable $id to another website to $_GET informations from it?
Problem: RewriteRule ^news/design-watches/(.*)/(.*)\.html$ news_view.php?category=$1&title=$2&id=$3
Result: http://localhost/news/design-watches/Technical-Data/Test-News-9.html
I'd like to exclude the ID part from the URL, but I will have to have it to pass informations between the sites.
Thanks for your answer!
If the URL does not contain a third capture pattern, then you can't use $3 in the rewrite target. And if your URL does not contain an ID value, there's no way to get that information from the URL for use later on.
So I don't think you can achieve what you're hoping to achieve.
This one's beyond my ability I'm afraid and after much research and breaking things I've come for help. I have a site with a URL in the format of:
example.com/7865/travel-photo/my-amazing-photo
My client has now decided he'd like to add an 's' onto photos so the URL has become:
example.com/7865/travel-photos/my-amazing-photo
All great and that alone wouldn't have been a problem only for the fact that the number '7865' changes for each URL just like the 'my-amazing-photo' does. The basic structure of the new URL needs to be:
example.com/'number variable'/travel-photos/'article name variable'
So my question how does write a beautiful htaccess mod rewrite rule for that?
RewriteEngine On
RewriteBase /
RewriteRule ^([0-9]+)/travel-photos/(.*) $1/travel-photo/$2