简体   繁体   中英

how to rewrite url using .HTACCESS and PHP

the below htacces code redirecting to only first link and not working for below two links .htaccess file

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ $1.php [L,QSA]

RewriteRule ^([-\w]+)$ stateProperty.php?state_name=$1 [NC,L]
RewriteRule ^([-\w]+)$ propertyTypes.php?property_types_name=$1 [NC,L]
RewriteRule ^([-\w]+)$ propertyStatus.php?property_status_name=$1 [NC,L]

php code

<a href="<?php echo str_replace(' ', '-', strtolower($countStateProjects['state_name'])) ?>" class="py-0 d-block">Properties In <?php echo $countStateProjects['state_name'];?>
<a href="<?php echo str_replace(' ', '-', $propertyTypes['property_types_name']) ?>" class="py-0 d-block"><?php echo $propertyTypes['property_types_name']; ?> for Sale in India/a>
<a href="<?php echo str_replace(' ', '-', $propertyStatus['property_status_name']) ?>" class="py-0 d-block"><?php echo $propertyStatus['property_status_name']; ?> Projects for Sale in India</a>

the below htacces code redirecting to only first link and not working for below two links .htaccess file

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ $1.php [L,QSA]

RewriteRule ^([-\w]+)$ stateProperty.php?state_name=$1 [NC,L]
RewriteRule ^([-\w]+)$ propertyTypes.php?property_types_name=$1 [NC,L]
RewriteRule ^([-\w]+)$ propertyStatus.php?property_status_name=$1 [NC,L]

php code

<a href="<?php echo str_replace(' ', '-', strtolower($countStateProjects['state_name'])) ?>" class="py-0 d-block">Properties In <?php echo $countStateProjects['state_name'];?>
<a href="<?php echo str_replace(' ', '-', $propertyTypes['property_types_name']) ?>" class="py-0 d-block"><?php echo $propertyTypes['property_types_name']; ?> for Sale in India/a>
<a href="<?php echo str_replace(' ', '-', $propertyStatus['property_status_name']) ?>" class="py-0 d-block"><?php echo $propertyStatus['property_status_name']; ?> Projects for Sale in India</a>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM