Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Sep 2010
    Location
    India
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts

    htaccess and url rewrite help

    Hello everyone,

    I have a social engine 3 website, in my website all URLS can be changed(URL-REWRITING) through the SE-url settings automatically, but in my website their is one module which is custom coded, where I have to set its URL manually in htaccess file,

    the url which I want to changes is this:

    mysite.com/institutes_desc.php?id=19

    I want this URL to be changed like

    mysite.com/institutes/intitute_name or mysite.com/institutes/intitute_id

    My htaccess file is this

    Code:
    RewriteEngine On
    Options +Followsymlinks
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.* - [L,QSA]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^.*/images/(.*)$ /images/$1 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^.*/uploads_user/(.*)$ /uploads_user/$1 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/?$ /profile.php?user=$1 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/([^/]+)?$ /profile.php?user=$1$2 [L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/documentgroups/([0-9]+)/([0-9]+)/([^/]+)/?$ /documentgroup.php?user=$1&documentgroup_id=$2&group_id=$3&title=$4 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/documentgroups/([0-9]+)/([^/]+)?$ /documentgroup.php?user=$1&documentgroup_id=$2$3 [L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/documents/([0-9]+)/([^/]+)/?$ /document.php?user=$1&document_id=$2&title=$3 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/documents/([0-9]+)/([^/]+)?$ /document.php?user=$1&document_id=$2$3 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/documents/?$ /documents.php?user=$1 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/documents/?$ /documents.php?user=$1 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^documents/tag/([^/]+)/?$ /browse_documents.php?tag=$1 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^documents/category/([0-9]+)/?$ /browse_documents.php?i=$1 [L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/blog/([0-9]+)/?$ /blog.php?user=$1&blogentry_id=$2 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/blog/([^/]+)?$ /blog.php?user=$1$2 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/blog/?$ /blog.php?user=$1 [L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/trackback/([0-9]+)/?$ /blog_ajax.php?task=trackback&user=$1&blogentry_id=$2 [L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/videos/([0-9]+)/?$ /video.php?user=$1&video_id=$2 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*/)?group/([0-9]+)/([^/]*)$ /group.php?group_id=$1$2$3 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*/)?group/([0-9]+)/album/([0-9]+)/([^/]*)$ /group_album_file.php?group_id=$2&groupmedia_id=$3$4 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*/)?group/([0-9]+)/discussion/([0-9]+)/([^/]*)$ /group_discussion_view.php?group_id=$2&grouptopic_id=$3$4 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*/)?group/([0-9]+)/discussion/([0-9]+)/([0-9]+)/([^/]*)$ /group_discussion_view.php?group_id=$2&grouptopic_id=$3&grouppost_id=$4$5 [L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/articles/([^/]+)?$ /articles.php?user=$1$2 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/articles/?$ /articles.php?user=$1 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^article/([0-9]+)(/[^/]*)?$ /article.php?article_id=$1&article_slug=$2 [L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/job/([0-9]+)/?$ /job.php?user=$1&jobentry_id=$2 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/job/([^/]+)?$ /job.php?user=$1$2 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/job/?$ /job.php?user=$1 [L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/trackback/([0-9]+)/?$ /job_ajax.php?task=trackback&user=$1&jobentry_id=$2 [L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/classifieds/([0-9]+)/?$ /classified.php?user=$1&classified_id=$2 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/classifieds/([0-9]+)/([^/]+)?$ /classified.php?user=$1&classified_id=$2$3 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/classifieds/?$ /classifieds.php?user=$1 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*/)?event/([0-9]+)/([^/]*)$ /event.php?event_id=$1$2$3 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*/)?event/([0-9]+)/album/([0-9]+)/([^/]*)$ /event_album_file.php?event_id=$2&eventmedia_id=$3$4 [L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^application/([0-9]+)/?$ /app.php?id=$1 [L]
    Can anyone help me in this? how can I set my url this way?

  • #2
    kgb
    kgb is offline
    New to the CF scene
    Join Date
    Aug 2009
    Posts
    7
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Backup your current configuration of the .htaccess and use the config below:

    Code:
    RewriteEngine On
    Options +Followsymlinks
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} -d [OR]
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule ^.* - [L]
    RewriteRule ^.*/images/(.*)$ /images/$1 [L]
    RewriteRule ^.*/uploads_user/(.*)$ /uploads_user/$1 [L]
    RewriteRule ^([^/]+)/?$ /profile.php?user=$1 [L]
    RewriteRule ^([^/]+)/([^/]+)?$ /profile.php?user=$1$2 [L]
    RewriteRule ^([^/]+)/documentgroups/([0-9]+)/([0-9]+)/([^/]+)/?$ /documentgroup.php?user=$1&documentgroup_id=$2&group_id=$3&title=$4 [L]
    RewriteRule ^([^/]+)/documentgroups/([0-9]+)/([^/]+)?$ /documentgroup.php?user=$1&documentgroup_id=$2$3 [L]
    RewriteRule ^([^/]+)/documents/([0-9]+)/([^/]+)/?$ /document.php?user=$1&document_id=$2&title=$3 [L]
    RewriteRule ^([^/]+)/documents/([0-9]+)/([^/]+)?$ /document.php?user=$1&document_id=$2$3 [L]
    RewriteRule ^([^/]+)/documents/?$ /documents.php?user=$1 [L]
    RewriteRule ^([^/]+)/documents/?$ /documents.php?user=$1 [L]
    RewriteRule ^documents/tag/([^/]+)/?$ /browse_documents.php?tag=$1 [L]
    RewriteRule ^documents/category/([0-9]+)/?$ /browse_documents.php?i=$1 [L]
    RewriteRule ^([^/]+)/blog/([0-9]+)/?$ /blog.php?user=$1&blogentry_id=$2 [L]
    RewriteRule ^([^/]+)/blog/([^/]+)?$ /blog.php?user=$1$2 [L]
    RewriteRule ^([^/]+)/blog/?$ /blog.php?user=$1 [L]
    RewriteRule ^([^/]+)/trackback/([0-9]+)/?$ /blog_ajax.php?task=trackback&user=$1&blogentry_id=$2 [L]
    RewriteRule ^([^/]+)/videos/([0-9]+)/?$ /video.php?user=$1&video_id=$2 [L]
    RewriteRule ^(.*/)?group/([0-9]+)/([^/]*)$ /group.php?group_id=$1$2$3 [L]
    RewriteRule ^(.*/)?group/([0-9]+)/album/([0-9]+)/([^/]*)$ /group_album_file.php?group_id=$2&groupmedia_id=$3$4 [L]
    RewriteRule ^(.*/)?group/([0-9]+)/discussion/([0-9]+)/([^/]*)$ /group_discussion_view.php?group_id=$2&grouptopic_id=$3$4 [L]
    RewriteRule ^(.*/)?group/([0-9]+)/discussion/([0-9]+)/([0-9]+)/([^/]*)$ /group_discussion_view.php?group_id=$2&grouptopic_id=$3&grouppost_id=$4$5 [L]
    RewriteRule ^([^/]+)/articles/([^/]+)?$ /articles.php?user=$1$2 [L]
    RewriteRule ^([^/]+)/articles/?$ /articles.php?user=$1 [L]
    RewriteRule ^article/([0-9]+)(/[^/]*)?$ /article.php?article_id=$1&article_slug=$2 [L]
    RewriteRule ^([^/]+)/job/([0-9]+)/?$ /job.php?user=$1&jobentry_id=$2 [L]
    RewriteRule ^([^/]+)/job/([^/]+)?$ /job.php?user=$1$2 [L]
    RewriteRule ^([^/]+)/job/?$ /job.php?user=$1 [L]
    RewriteRule ^([^/]+)/trackback/([0-9]+)/?$ /job_ajax.php?task=trackback&user=$1&jobentry_id=$2 [L]
    RewriteRule ^([^/]+)/classifieds/([0-9]+)/?$ /classified.php?user=$1&classified_id=$2 [L]
    RewriteRule ^([^/]+)/classifieds/([0-9]+)/([^/]+)?$ /classified.php?user=$1&classified_id=$2$3 [L]
    RewriteRule ^([^/]+)/classifieds/?$ /classifieds.php?user=$1 [L]
    RewriteRule ^(.*/)?event/([0-9]+)/([^/]*)$ /event.php?event_id=$1$2$3 [L]
    RewriteRule ^(.*/)?event/([0-9]+)/album/([0-9]+)/([^/]*)$ /event_album_file.php?event_id=$2&eventmedia_id=$3$4 [L]
    RewriteRule ^application/([0-9]+)/?$ /app.php?id=$1 [L]
    RewriteRule ^institutes/([0-9]+)$ /institutes_desc.php?id=$1 [L]

    Example urls would be http://yoursite.com/institutes/1 , http://yoursite.com/institutes/2, 3 and so on.
    Last edited by kgb; 04-23-2011 at 04:00 PM.

  • #3
    New Coder
    Join Date
    Sep 2010
    Location
    India
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts
    not working, it still shows me the old URL

  • #4
    kgb
    kgb is offline
    New to the CF scene
    Join Date
    Aug 2009
    Posts
    7
    Thanks
    0
    Thanked 2 Times in 2 Posts
    You should change the links in your website code to point to the new destination.

    Look for something like <a href="mysite.com/institutes_desc.php?id=$SomeVar">probably some text</a> and change it to <a href="mysite.com/institutes/$SomeVar"></a>

    http://yoursite.com/institutes/19

    Also copy the link above, replace yoursite.com with the actual sub/domain of the website in question, paste the link with the replaced url in your browsers address bar and try to open it.

  • #5
    New Coder
    Join Date
    Sep 2010
    Location
    India
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have too many pages with this URL,
    If I keep on editing each of them, then it will be longggg

    Their is no other way so that all that will be redirected to the new URL?

  • #6
    New Coder
    Join Date
    Sep 2010
    Location
    India
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    Quote Originally Posted by kgb View Post
    You should change the links in your website code to point to the new destination.

    Look for something like <a href="mysite.com/institutes_desc.php?id=$SomeVar">probably some text</a> and change it to <a href="mysite.com/institutes/$SomeVar"></a>

    http://yoursite.com/institutes/19

    Also copy the link above, replace yoursite.com with the actual sub/domain of the website in question, paste the link with the replaced url in your browsers address bar and try to open it.
    In URL when I type then the page opens,
    but I cant edit all files with this URL,
    Is their any htaccess rule, where all old URLS will be directed to the new one?


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •