I am trying to make seo friendly url for my page http://www.jobslamp.com/jobsbystate.php?s=af3d1405&st=Kerala . I have tried some htacess code before , but then the designs are lost. Could u plz suggest the proper htacess code to achieve this . I would like to get an url like http://www.jobslamp.com/jobsbystate.php/af3d1405&st/Kerala
Thanks in advance
This sounds like you're linking to CSS or javascript using relative URI's instead of absolute URI's. You can either make all of your links absolute by adding a leading slash (for example):
<link rel="stylesheet" href="main.css" type="text/css">
to:
<link rel="stylesheet" href="/main.css" type="text/css">
Or you can define the URI base in the header of your pages by adding:
<base href="/">
or whatever the base should be.
Related
I am quite new to node and I am trying to wrap my head around how the express.static middleware is working. In my views folder I have some href's like this:
<link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
My application is able to grab these files form URLS's such as localhost/about, localhost/contact etc. However it will not grab files if the end point is something like localhost/form/new. Is express.static getting these static assets from localhost/somefile and when there is a nested URL it defaults to /form/somefile (which won't work)? I am aware that if you put a '/' before vendor it will work from any level, why is this? Thank you.
app.use(express.static(“public”));
That is a way of saying "hey express, look if any incoming requests (like GET /bundle.css matches a file on that directory, if so, send it!".
Any file on that directory, you should be able to access under /. If you're serving from your localhost and have bundle.css on public folder, you can visit http://localhost/bundle.css.
Any asset you're trying to get from public folder, should start with / meaning look for an absolute path (in this case, the path public folder is serving which is /).
Update
There is another way of doing that using relative path which is not recommendable.
If you're in /about/index.html and you're trying to get /css/bundle.css (under public's folder)
Absolute Path:
<link rel="stylesheet" href="/css/bundle.css">
Relative Path: (not recommendable)
<link rel="stylesheet" href="../css/bundle.css">
The only thing to keep in mind is to make a slash mark before the static file address.
<link rel="shortcut icon" href="/img/favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="/css/style.css" type="text/css">
If you do not put this slash before the address, you will have a problem loading styles, images, etc. in the nested addresses.
For example, if you use the following addressing instead of the above operation, you will definitely have problems in the nested URL.
<link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="css/style.css" type="text/css">
This is especially useful on page 404.
I have bone.php and bone.css inside public_html in my server. Inside bone.php i have a link tag which calls bone.css <link rel="stylesheet" type="text/css" href="bone.css">. i have created .htaccess file for bone.php file
RewriteRule ^community/([0-9a-zA-Z]+) bone.php?first=$1 [NC, L]
After i created .htaccess i need to change link tag like <link rel="stylesheet" type="text/css" href="../bone.css">. Which means bone.php thinks its inside a folder, which is not.
If its only way i need change all links inside my website. I hope someone will say there is an another way.Thanks
This is because your relative URIs have their base changed. Originally, the base is / when the page is /bone.php, and the browser properly fills in relative links with the / base. But when the browser goes to a page like /community/foo/ the base suddenly becomes /community/foo/ 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="/">
I am using MOD_REWRITE to channel all URLs through a single file. The aim is to allow pretty urls like:
http://mysite.com/shop/electrical/hoover
or
http://mysite.com/shop/checkout
etc etc
I achieve this using the following .htaccess file:
# Turn on the RewriteEngine
RewriteEngine On
#
# Rules
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . urlbug.htm
This is the stripped down HTML file that does all the work:
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8">
<title>My web page</title>
<link type="text/css" href="css/ui-lightness/jquery-ui-1.8.20.custom.css" media="all" rel="stylesheet"/>
</head>
<body>
<div id="accordion"><h3>Home</h3><div>
<ul class="submenu"><li>Clear Counters</li></ul>
</div>
<h3>Maintan Tables</h3>
<div>
<ul class="submenu">
<li>Stock</li>
<li>Categories</li>
<li>Designers</li>
</ul>
</div>
<h3>User Database</h3><div><ul class="submenu"></ul></div>
</div>
<script src="js/libs/jquery-1.7.1.min.js"></script>
<script src="js/libs/jquery-ui-1.8.20.custom.min.js"></script>
<script src="js/plugins.js"></script>
</body></html>
This works if you visit a URL like:
http://www.facebookanswers.co.uk/code/foobar/works
However, if you try a URL like:
http://www.facebookanswers.co.uk/code/foobar/no/longer/works
Then the URL will load, however, none of the CSS or JS files will load.
This is because I am using relative URLs.
If I instead use absolute URLs, then all works fine. I have set up a different folder to demonstrate this:
http://www.facebookanswers.co.uk/code/foobar2/works
and
http://www.facebookanswers.co.uk/code/foobar2/works/as/well
This is the code with the absolute URLs:
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8">
<title>My web page</title>
<link type="text/css" href="http://www.facebookanswers.co.uk/code/foobar2/css/ui-lightness/jquery-ui-1.8.20.custom.css" media="all" rel="stylesheet"/>
</head>
<body>
<div id="accordion"><h3>Home</h3><div>
<ul class="submenu"><li>Clear Counters</li></ul>
</div>
<h3>Maintan Tables</h3>
<div>
<ul class="submenu">
<li>Stock</li>
<li>Categories</li>
<li>Designers</li>
</ul>
</div>
<h3>User Database</h3><div><ul class="submenu"></ul></div>
</div>
<script src="http://www.facebookanswers.co.uk/code/foobar2/js/libs/jquery-1.7.1.min.js"></script>
<script src="http://www.facebookanswers.co.uk/code/foobar2/js/libs/jquery-ui-1.8.20.custom.min.js"></script>
<script src="http://www.facebookanswers.co.uk/code/foobar2/js/plugins.js"></script>
</body>
</html>
Somewhere along the line, the path is getting confused. What is the best way around this? I would like to keep relative URLs if possible, as the code I am developing will be used on a number of sites. Its not the end of the world if I have to use absolute URLs, and I know that there are performance benefits in absolute URLs, but it seems odd that the browser will happily load the URL, but then think that it is stored somewhere else!
Use root relative URLs.
The problem is that the browser sees a URL like http://www.facebookanswers.co.uk/code/foobar/no/longer/works so a relative link would resolve as http://www.facebookanswers.co.uk/code/foobar/no/longer/works/code/foobar2/css... and so on.
Instead use this...
<link type="text/css" href="/code/foobar2/css/ui-lightness/jquery-ui-1.8.20.custom.css" media="all" rel="stylesheet"/>
By starting with a / you're forcing it to be relative to the root of the website, but by not specifying the domain, it'll work just fine if you deploy on another site. This is really just an HTML issue rather than a mod-rewrite one.
Take a look at your server access logs and you'll see what pages are being requested, and you'll see they're not what you were expecting.
Site-wide resources are always best referred to with root-relative URLs - it means you don't need to adjust them based on where you are in the site, and it makes them portable between sites (which is handy if, like me you have your development site on a local machine with a different domain name - I use www.example.com.dev when working locally on www.example.com)
I have the canonical line in a huge pages as below
<link rel="canonical" href="10-effective-ways-to-reduce-merchant-cash-advance-business-costs.php" />
sure every page has it's own url, I want to search this line for all the pages and change .php to be .html
I hope if you can help
I found the solution find
<link rel="canonical"([^<]*).php
replace with
<link rel="canonical"$1.html
I'm moving an web application to a subdirectory from it's root and having issues with paths.
Old: http://www.domain.com/
New: http://www.domain.com/app/
All of the include css, scripts and html links where in this format:
<link rel="stylesheet" type="text/css" href="/styles/menu.css" media="screen"/>
I've changed to:
<link rel="stylesheet" type="text/css" href="./styles/menu.css" media="screen"/>
or
<link rel="stylesheet" type="text/css" href="~/styles/menu.css" media="screen"/>
It works fine on links and others until I go one directory deep where links and paths are broken.
e.g.
www.domain.com/app/dir1/
www.domain.com/app/dir2/
There the link url or others (scripts, includes, etc) get duplicate paths.
e.g.
www.domain.com/app/dir1/dir1/
www.domain.com/app/dir2/dir2/
How could I approach this as absolute?
Using ~/style... etc is the easiest solution in ASP.NET but you must put runat="server" in the tag for it to actually work