Jump to content

.htaccess mod rewrite for ugly links ?


plodos

Recommended Posts

I create this file and upload the root directory in my FTP.

.htaccess

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^topic-([0-9]+)/[A-Z0-9_-]+\.html$ /aaa.php?page=$1 [NC,L]
RewriteRule ^topic-([0-9]+)/[A-Z0-9_-]+\.html$ /bbb.php?page=$1 [NC,L]
RewriteRule ^topic-([0-9]+)/[A-Z0-9_-]+\.html$ /ccc.php?page=$1 [NC,L]

 

But the links are same Ugly mode like

example: http://www.aaa.com/aaa.php?page=3

 

It must be pretty URL like

example: /topic-41/favourite-cheese.html

 

What is the problem?

Link to comment
Share on other sites

I changed it. But still ugly links.

.htaccess

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^folder/([^/\.]+).htm$ folder/aaa.php?page=$1 [L] 

 

Do I need to create a "folder" directory ?

 

I dont have any directory..All links are inside of the FTP root.

like http://www.aaa.com/aaa.php?page=387

http://www.aaa.com/index.php

http://www.aaa.com/contact_us.php

 

still I didnt understand whats wrong:s

Link to comment
Share on other sites

Oops, Sorry i gave you the wrong one.

Here:

 

2. Description - Your current URL is

http://www.example.com/index.php?cat=category&subcat=subcategory

which you would like to see as

http://www.example.com/category/subcategory

Solution - Put the below lines in your .htaccess file

 

RewriteEngine on

RewriteRule ^([^/\.]+)/([^/\.]+)/?$ /index.php?cat=$1&subcat=$2 [L]

Link to comment
Share on other sites

"1. Description - Your current pages are called using index.php with parameter of url i.e

http://www.example.com/index.php?url=category

and instead of this URL, you want a nice and easy to read URL like http://www.example.com/category

Solution - Put the following lines in your .htaccess file.

 

RewriteEngine on

RewriteRule ^([^/\.]+)/?$ /index.php?url=$1 [L] "

 

-------------------------------------------------------------------------------------

 

this is my new .htaccess

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^([^/\.]+)/?$ /aaa.php?page=$1 [L]
RewriteRule ^([^/\.]+)/?$ /bbb.php.php?page=$1 [L]
RewriteRule ^([^/\.]+)/?$ /ccc.php?page=$1 [L]

 

this link http://www.aaa.com/aaa.php?page=387

must be http://www.aaa.com/387

but still same problem, still ugly links!!

 

 

"Step5. Call the file in the url - http://your-domain.com/info.php and check if you see mod_rewrite in ‘Apache loaded modules’ section. If NOT, then please contact your hosting provider and request them to install/enable mod_rewrite."

 

 

I checked my info.php. I didnt find anything about mod_rewrite!! There is no mod_rewrite section...What will happen?

Link to comment
Share on other sites

this is my code to make pagination like

http://www.aaa.com/aaa.php?page=387

http://www.aaa.com/aaa.php?page=93

 

and I want to convert it pretty URLs because google doesnt like ugly URLs

 

my .htaccess file doesnt convert these links:S

 

These are the rewritten links! Please check my codes..Am I right ?

 

<?php
function title_case($title) {
////////////////////////////////
}
$page = $_GET["page"]; 
if(empty($page) or !is_numeric($page)){ 
$page = 1;
}

$limit = 25; 
$satirsayisi = mysql_num_rows(mysql_query("select * from person where c_no='2' AND date < NOW() - INTERVAL 7 HOUR")); 
$sayfasayisi = ceil($satirsayisi / $limit); 
$baslangic = ($page-1)*$limit; 

$data = mysql_query("select * from person where c_no='2' AND date < NOW() - INTERVAL 7 HOUR ORDER BY lname ASC LIMIT $baslangic,$limit"); 

                     
while($info=mysql_fetch_array($data))
{
echo title_case($info['lname'])." ".title_case($info['fname']).", <br>";
}

if($page > 1){ 
$back = $page-1;
echo "<p align=\"center\"><b><a href=\"aaa.php?page=$back\"><< Back </a>";

}else{ 

echo "<p align=\"center\"><b> << Back ";
}

echo " | ";

if($page>=$sayfasayisi){ 

echo "Next >> </b></p>";

}else{ 

$next = $page+1;

echo "<a href=\"aaa.php?page=$next\">Next >></a></b></p>";
}
?>[code]

Link to comment
Share on other sites

In my opinion I found the solution:S

this is my pagination link

echo "<a href=\"aaa.php?page=$next\">Next >></a></b></p>";

 

and this is my .htaccess

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^([^/\.]+)/?$ /aaa.php?page=$1 [L]
RewriteRule ^([^/\.]+)/?$ /bbb.php?page=$1 [L]
RewriteRule ^([^/\.]+)/?$ /ccc.php?page=$1 [L]

 

In my opinion I have to change the pagination links

echo "<a href=\"aaa.php?page=$next\">Next >></a></b></p>";

to

rewritten links

[s]href="/page/?$next/.html"[/s]

something like that

 

 

Link to comment
Share on other sites

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.