plodos Posted November 6, 2008 Share Posted November 6, 2008 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 https://forums.phpfreaks.com/topic/131706-htaccess-mod-rewrite-for-ugly-links/ Share on other sites More sharing options...
dezkit Posted November 6, 2008 Share Posted November 6, 2008 6. Description - Your URL is http://example.com/folder/index.php?page=hello which you want to see as http://example.com/folder/hello.htm Solution - Place the following lines in your .htaccess file RewriteEngine on RewriteRule ^folder/([^/\.]+).htm$ folder/index.php?page=$1 [L] Link to comment https://forums.phpfreaks.com/topic/131706-htaccess-mod-rewrite-for-ugly-links/#findComment-684133 Share on other sites More sharing options...
dezkit Posted November 6, 2008 Share Posted November 6, 2008 Source: http://www.bloghash.com/2006/12/apache-mod_rewrite-examples/ Link to comment https://forums.phpfreaks.com/topic/131706-htaccess-mod-rewrite-for-ugly-links/#findComment-684139 Share on other sites More sharing options...
plodos Posted November 6, 2008 Author Share Posted November 6, 2008 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 https://forums.phpfreaks.com/topic/131706-htaccess-mod-rewrite-for-ugly-links/#findComment-684146 Share on other sites More sharing options...
dezkit Posted November 6, 2008 Share Posted November 6, 2008 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 https://forums.phpfreaks.com/topic/131706-htaccess-mod-rewrite-for-ugly-links/#findComment-684153 Share on other sites More sharing options...
plodos Posted November 6, 2008 Author Share Posted November 6, 2008 "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 https://forums.phpfreaks.com/topic/131706-htaccess-mod-rewrite-for-ugly-links/#findComment-684173 Share on other sites More sharing options...
corbin Posted November 6, 2008 Share Posted November 6, 2008 You do know that links are rewritten inside of your files, yes? If you go to one of the URLs that should be rewritten, does it work? Link to comment https://forums.phpfreaks.com/topic/131706-htaccess-mod-rewrite-for-ugly-links/#findComment-684194 Share on other sites More sharing options...
plodos Posted November 7, 2008 Author Share Posted November 7, 2008 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 https://forums.phpfreaks.com/topic/131706-htaccess-mod-rewrite-for-ugly-links/#findComment-684273 Share on other sites More sharing options...
dezkit Posted November 7, 2008 Share Posted November 7, 2008 RewriteEngine on RewriteRule ^([^/\.]+)/?$ /[b]INSERT YOUR PAGE NAME[/b].php?page=$1 [L] Put ONLY that. Link to comment https://forums.phpfreaks.com/topic/131706-htaccess-mod-rewrite-for-ugly-links/#findComment-684274 Share on other sites More sharing options...
plodos Posted November 7, 2008 Author Share Posted November 7, 2008 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 https://forums.phpfreaks.com/topic/131706-htaccess-mod-rewrite-for-ugly-links/#findComment-684281 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.