I want to rewrite my links but with multi styles
here is i want i want to be look like
Info cms is my Rewrite Base
Cats style
http://www.site.com/catname
Post Style
http://www.site.com/anycatname/posttitle
Pages Style
http://www.site.com/page/page+title+here
My Pages is
cats style => cats.php?name=catname
posts style => posts.php?title=posttitle
page style => page.php?name=catname
Note
As I tried to make url rewrite as in posts style css and js files had many problem too
See below url
http://corz.org/serv/tricks/htaccess2.php
or try below
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^files/([^/]+)/([^/]+).zip /download.php?section=$1&file=$2 [NC]
would allow you to present this link as..
mysite/files/games/hoopy.zip
and in the background have that transparently translated, server-side, to..
mysite/download.php?section=games&file=hoopy
Related
I want to make my URL as SEO Friendly URL. I tried editing .htaccess file by rewriting rule
RewriteRule ^swift-details/([0-9]+)/([0-9a-zA-Z_-]+)$ swift-details.php?id=$1 [NC,L]
RewriteRule ^swift-details/(css|js|img)/(.*)?$ /$1/$2 [L,QSA,R=301]
It's routing the correct URL but in that page CSS JS and images are not working.
Example URL:
http://www.example.com/swift-details/2/abblinbb
This is because your relative URIs have their base changed. Originally, the base is / when the page is /swift-details.php?id=foo, and the browser properly fills in relative links with the / base. But when the browser goes to a page like /swift/details/foo the base suddenly becomes /swift/ and it tries to append that in front of all relative URLs and thus none of them load.
You can either make your links absolute, or change the URI base in the header of your pages (inbetween the <head> </head> tags):
<base href="/">
You dont need the second rewrite rule. Your CSS/JS paths are all 'relative' to your current location.
Your CSS exists here:
/css/normalize.css
Your page is looking here:
/swift-details/2/abblinbb/css/normalize.css
All you need is 'forward-slashes' before your CSS/JS paths.
I have a website too extensive editing the URLs of styles css and files js, images would cost me too much time.
I'm working at localhost
localhost/project/index.php
The friendly url I want to have:
localhost/project/index/
From this url
localhost/project/online.php
to this
localhost/project/online/video/hd/free/
I have observed this website http://crazycafe.net/demos/seo/ and its source code, the styles css is maintained this way: <link href="css/bootstrap.min.css" rel="stylesheet" type="text/css">
without adding an absolute URL to styles css and their files and images.
How do i create a friendly url this way?
If the user modifies the url in this way:
http://crazycafe.net/demos/seo
Redirect to this way:
http://crazycafe.net/demos/seo/
On the other hand like conserving the styles css the files js and images, without having to modify to an absolute route.
My file directory is:
assets/css/style.css
assets/js/app.js
assets/fonts/icons/image.png
assets/fonts/ttf/roboto.ttf
assets/img/system/image.png
assets/img/logo.png
Note:
I found this question in SO, of how conserve CSS styles.
But I do not understand the use of friendly URL - .httaccess
You need to switch on mod_rewrite and use it. Example:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^folder1.*$ http://example.com/ [R=301,L]
Folder-based example:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^folder1/(.*)$ http://gs.mt-example.com/folder2/$1 [R=301,L]
Your case:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^online.php$ project/online/video/hd/free/$1 [R=301,L]
See more here.
I want to make my URL as SEO Friendly URL. I tried editing .htaccess file by rewriting rule
RewriteRule ^swift-details/([0-9]+)/([0-9a-zA-Z_-]+)$ swift-details.php?id=$1 [NC,L]
RewriteRule ^swift-details/(css|js|img)/(.*)?$ /$1/$2 [L,QSA,R=301]
It's routing the correct URL but in that page CSS JS and images are not working.
Example URL:
http://www.example.com/swift-details/2/abblinbb
This is because your relative URIs have their base changed. Originally, the base is / when the page is /swift-details.php?id=foo, and the browser properly fills in relative links with the / base. But when the browser goes to a page like /swift/details/foo the base suddenly becomes /swift/ and it tries to append that in front of all relative URLs and thus none of them load.
You can either make your links absolute, or change the URI base in the header of your pages (inbetween the <head> </head> tags):
<base href="/">
You dont need the second rewrite rule. Your CSS/JS paths are all 'relative' to your current location.
Your CSS exists here:
/css/normalize.css
Your page is looking here:
/swift-details/2/abblinbb/css/normalize.css
All you need is 'forward-slashes' before your CSS/JS paths.
I am trying to rewrite the urls of a site, i should mention that the way index.php works now is getting the p (page) parameter and including the appropriate file.
So requesting a page is like this:
www.domain.com/index.php?p=home
www.domain.com/index.php?p=search
www.domain.com/index.php?p=profile
www.domain.com/index.php?p=contact
I found how to create a rewrite rule for this:
RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?p=$1
so now www.domain.com/home would give me the home page
But i also need to have a friendly url for this
www.domain.com/index.php?p=profile&id=20
to
www.domain.com/profile/20/profile-friendly-name
or better
www.domain.com/profile/profile-friendly-name
*The profile-friendly-name refers to a company name
Requirements:
To have friendly urls for all pages e.g. /home, /contact
To have a particular friendly url for the profile page with the
profile name in the url
My questions:
How can i add a profile-friendly-name to the url with the existing url format (index.php?p=profile&id=20)?
Can i only have a unique name there (without the id), like my last
example?
If i manage to do that, will i have to change ALL the existing urls
within the site (links, urls to images, to files) to the friendly
format?
I noticed that after applying the first RewriteRule some css
stylesheets and js are not included. What is wrong?
RewriteRule ^profile/([0-9]+)/([A-Za-z0-9-]+)/?$ index.php?p=profile&id=$1
Should work for :
www.domain.com/index.php?p=profile&id=20
to
www.domain.com/profile/20/profile-friendly-name
Ex 1 :
https://example.com/books.php?bookName=php using htaccess url will be written like this https://example.com/php
You can do this using code given below in .htaccess file:
RewriteEngine On
RewriteRule ^([^/\.]+)/?$ books.php?bookName=$1
Ex 2 :
https://example.com/books.php?bookName=php&&chapter=array using htaccess url will be written like
https://example.com/php/array
You can get by using code in .htaccess file given below:
RewriteEngine On
RewriteRule ^([^/\.]+)/([^/\.]+)?$ books.php?bookName=$1&chapter=$2
I have used .htaccess in the past to rewrite my URLs.
I used things like this:
RewriteRule event-([0-9]+)-([^.]+)\.html$ /event.php?id=$1 [L]
BUT really prefers directory style:
RewriteRule ^events/([a-z]+) events.php?cat=$1 [NC]
My question is that it has always bothered me in the HTML with the directory style to add this kind of code to link images, includes(); and other links when the directory gets long when with the first style I don't have to change anything.
../../../images.jpg
../../../../../script.php
Is there an other way to code this because it's really bad like thisnd gets on my nerves each time.
Assuming that you have the folder structure like :
css [folder]
images [folder]
event.php
events.php
index.php
etc.
You could use in your html : base and at that point you can just link your css and images like normal.