morowind
Posts: 46
|
| Posted: 03/17/2010, 7:39 AM |
|
I saw all the posts on Google and forum mod_rewrite but I seem to understand how it works.
Please help me with following problem:
Page: http://localhost/classifieds/listitems.php?catFirst=Rea...l&catThird=Land
rewrite to: http://localhost/classifieds/Real-Estate/Comercial/Land/
What code should I have in. htaccess and what changed to be done in the script. php?
Of course I found many examples but does not work either.
I am sure that mod_rewrite is enabled becouse simple rewrite works.
When I accessing the page http://localhost/classifieds/Real-Estate/Comercial/Land/ the page opens but without. js and. css file.
If you can - anybody - please provide a complete example .I think it could help manny CSS users
Thanks in advance
best regards to everybody
|
 |
 |
melvyn
Posts: 333
|
| Posted: 03/17/2010, 7:50 AM |
|
As told in PM:
Hi,
Since you said:
"When I accessing the page http://localhost/classifieds/Real-Estate/Comercial/Land/ the page opens but without. js and. css file."
That's mean your .htaccess is working well. No matter with .htaccess; instead you need to fix the paths to .css an .js files.
Modify both .css and .js files in order to get the path as:
<script type="text/javascript" src="/classifieds/path-to-script"...
<link rel="stylesheet" href="/classifeds/path-to-css" ...
That's the only issues you have.
M.
_________________
Melvyn Perez
Puro Codigo
http://purocodigo.com |
 |
 |
morowind
Posts: 46
|
| Posted: 03/17/2010, 8:05 AM |
|
I did that. http://localhost/Styles/classifieds/Style_doctype.css
Also: .. / Styles / classifieds / Style_doctype.css
Doesn't work
and even when put mouse on a link is not changed mod_rewrite ex: http://localhost/classifieds/Real-Estate/Comercial/Land/
Please if you can put a complete example
Thanks
|
 |
 |
melvyn
Posts: 333
|
| Posted: 03/17/2010, 8:57 AM |
|
You're posting links to your local site. Upload a sample and post link here.
<link rel="stylesheet" type="text/css" href="/classifeds/Styles/classifieds/Style_doctype.css" >
_________________
Melvyn Perez
Puro Codigo
http://purocodigo.com |
 |
 |
morowind
Posts: 46
|
| Posted: 03/17/2010, 10:27 AM |
|
I got it ! thank you verry much! works!
Now what I shoud change in my CSS link's to show like
<a href="http://localhost/classifieds/Real-Estate/Comercial/Land/">Land</a>
thank's again.
For others like me :
ajust and write the code in your .htaccess file
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^listitems/(.*)/ /classifieds/listitems.php?catFirst=$1& [L]
I will post my entire and comment code when I finish!
|
 |
 |
feha
Posts: 712
|
| Posted: 03/17/2010, 12:55 PM |
|
Hi
add this in to HTML template
<base href="http://localhost/" />
or
<base href="http://localhost/classifieds/" />
between <head> </head> tags ...
this will fix your problem with relative paths ...
else you will need absolute paths to all scripts and css ...
_________________
Regards
feha
www.vision.to
feedpixel.com |
 |
 |
feha
Posts: 712
|
| Posted: 03/17/2010, 1:03 PM |
|
Quote :Now what I shoud change in my CSS link's to show like <a href="http://localhost/classifieds/Real-Estate/Comercial/Land/">Land</a>
There is no automatic way to create this from CCS,
you will need a custom function that will replace - change link format that you desire ...
_________________
Regards
feha
www.vision.to
feedpixel.com |
 |
 |
morowind
Posts: 46
|
| Posted: 03/17/2010, 1:05 PM |
|
Thank's feha,
Can you provide some guidance or example ?
|
 |
 |
feha
Posts: 712
|
| Posted: 03/17/2010, 1:14 PM |
|
A short example:
$seo_url = str_replace(array('index.php','//','&','&'), array('','/','/','/'), $url);
note: the secon & is & amp; but forum converts it to &
you will need to get url value before show
than to set link ...
read more about Link porperty (Help or Manual)
Sorry , I have no time to provide you with full custom solution in this case of your project ...
here is in practice:
$url = $Component->GetLink();
$seo_url = str_replace(array('index.php','//','&','&'), array('','/','/','/'), $url);
$Component->SetLink( $seo_url);
This can work if you apply on BeforeShow event to link component ...
in str_replace array you can add more characters you want to replace as = + etc ...
_________________
Regards
feha
www.vision.to
feedpixel.com |
 |
 |
feha
Posts: 712
|
| Posted: 03/17/2010, 1:39 PM |
|
Hope the above solution helps others too ...
_________________
Regards
feha
www.vision.to
feedpixel.com |
 |
 |
morowind
Posts: 46
|
| Posted: 03/18/2010, 5:45 AM |
|
Im back
thank's feha and melvyn
I try yours solutions and works fine everything .thank's again
Also I try Valentin Agachi’s script - Rewriting dynamic URLs into friendly URLs -
http://agachi.name/weblog/archives/2005/01/30/rewriting...iendly-urls.htm
But...
I have the fallowing problem :
when : http://localhost/classifieds/listitems/catFirst/Antiques/ and works fine (query etc)
but when :http://localhost/classifieds/listitems/catFirst/Real+Estate/ doesn't work
this is regex code :
define('BASE_URL', '/'); // this you must use as an absolute path to the application root, ex: /folder1/folder2/
if (isset($_SERVER['PATH_INFO'])) {
$url = substr($_SERVER['PATH_INFO'], 1);
$urlParts = explode('/', $url);
if ($urlParts[count($urlParts) - 1] == '') array_pop($urlParts);
$urlPartsCount = count($urlParts);
if ($urlPartsCount % 2 != 0) {
$urlPartsCount++;
}
for ($i = 0; $i < $urlPartsCount; $i += 2) {
$_GET[$urlParts[$i]] = $urlParts[$i + 1]; } }
$urlPatterns = array( '~'.preg_quote(BASE_URL).'([^\.]+).php(\?([0-9a-zA-Z]+[^#"\']*))?~i', );
ob_start();
can you guy's help me with this ?
|
 |
 |
datadoit
|
| Posted: 03/18/2010, 5:56 AM |
|
Coffee?
|
|
|
 |
feha
Posts: 712
|
| Posted: 03/18/2010, 5:58 AM |
|
if you use mod_rewrite, you don't need Agachi’s script ....
_________________
Regards
feha
www.vision.to
feedpixel.com |
 |
 |
morowind
Posts: 46
|
| Posted: 03/18/2010, 6:08 AM |
|
yes I know but for lazy guy like me this script rewrite all links in page
thank's
|
 |
 |
feha
Posts: 712
|
| Posted: 03/18/2010, 6:28 AM |
|
No medicine for laziness
_________________
Regards
feha
www.vision.to
feedpixel.com |
 |
 |
morowind
Posts: 46
|
| Posted: 03/18/2010, 7:09 AM |
|

Thank you.
I will prepare a tutorial with all things put together.
|
 |
 |
mamboBROWN
Posts: 1713
|
| Posted: 03/18/2010, 7:21 AM |
|
morowind
Please don't forget to add [Solved] or [Resolved] in your thread title. Thanks.
|
 |
 |