Jump to content

Recommended Posts

i am trying to implement seo friendly url to my website. for page where no parameter passed, the url becomes fine i.e., without php extension but where i am sending variable parameter, it does not change. Please check below 2 type of code i try to implement.

First code in htaccess:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ makeurl.php?url=$1 [QSA,L]

makeurl.php code:

<?php
//echo "<pre>";
//print_r($_SERVER);
$hid = $_GET['hid'];
$request = $_SERVER['REQUEST_URI'];
//echo "<br>";
$router = str_replace('/wavehotels', '', $request);

if($router == '/'){
    include('index.php');
}elseif($router == '/hotels'){
    include('hotels.php');
}elseif($router == 'hotel-detail' || preg_match("/hotel-detail\/[0-9]/i", $router)){
    include('hotel-detail.php');  
}elseif($router == '/destinations'){
    include('destinations.php');
}elseif($router == '/about-us'){
    include('about-us.php');
}elseif($router == '/blogs'){
    include('blogs.php');
}elseif($router == '/contact-us'){
    include('contact-us.php');
}else{
    include('404.php');
}
?>

i m getting result for nornal pages:

www.abc.com/about.php is result in www.abc.com/about

 

but the issue is in where parameter passed like www.abc.com/product.php?id=2

no change in this url,  i want the result like www.abc.com/product/2

any input will be appreciated.

Thanks

Himanshoo

Link to comment
https://forums.phpfreaks.com/topic/315424-not-getting-result-for-desited-url/
Share on other sites

i re write my code which works fine when writing url manually not from anchor tag

Options +FollowSymlinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^detail/([0-9]+)$ hoteldetail?hid=$1 [QSA,L]

when i type manually it displays data fine like www.abc.com/detail/4

but when i come from anchor tag from main page it display url like www.abc.com/hoteldetail?hid=2

url not changed but data displays perfect.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.