Jump to content

cags

Staff Alumni
  • Posts

    3,217
  • Joined

  • Last visited

Posts posted by cags

  1. Do you have access to edit the VirtualHost? It's certainly not going to be possible to do anything using .htaccess, but theoretically it may be possible to redirect from the vhost. Information in the request is encrypted so you won't have access to it until a certificate is loaded, but it must know what port the connection came in on, it may therefore be theoretically possible to redirect at that point.

  2. This can't be done purely via .htaccess, it's not magic, if the value isn't in the URL, then you can't use it in the script. You would need to update your script to fetch information from the database using 'article-title' instead of using the id (12). Basically you change the title to be the identifier of the article. Thus obviously it would need to be unique. Given the URL you describe it would seem you are already using mod_rewrite rules, these would just need a bit of tweaking to not match the id.

  3. Are you saying that on your server you have a directory in your root called city that has an FL folder with a Miami.html file inside of it and that you wish the url to appear as just /FL/Miami.html without the word city?

     

    RewriteEngine On
    RewriteRule ^(FL/Miami\.html)$ /city/$1 [L]

     

    I assume you have more than just the one URL you wish to rewrite, but since you didn't specify any parameters, I'm not going to bother hypothesising as I could be completely off. Either way it's just a matter of creating the correct regular expression to match the first half.

  4. OK, so we have a page on our site that works, it's a post with the id of 121 and is accessed via the URL http://mysite.com/viewItem.php?id=121, this is all fine and dandy but it's not as pretty as we would like to be, we want people to access it via http://mysite.com/121/border-collie-for-sale-to-good-home.

     

    Step 1: We need to use mod_rewrite in order to take a request for /121/border-collie-for-sale-to-good-home and serve up /viewItem.php?id=121.

     

    RewriteEngine On

    RewriteRule ^([0-9]+)/[a-z-]+/?$ /viewItem.php?id=$1 [L]

     

    We should now be able to type /121/border-collie-for-sale-to-good-home into our address bar, and view the page.

     

    Step 2: We need to update the links in our script so that they link to this newly beautified url.

     

    <a href="/<?php echo $postid;?>/<?php echo $thetitle;?>"

     

    Step 3: Celebrate.

     

    There are various nuances that can trip you up along the way, but this is essentially all the steps required.

     

  5. If a period is a required character, just add it into the first character set. Incidentally I see you are checking that the request doesn't end in a question mark. The query_string question mark is not part of the string tested against, not I believe a URL safe character.

  6. Windows 7 most certainly isn't ignoring your config file. If anything then it's likely you have another web server such as IIS installed and it is this listening on port 80, not apache (or you are looking at the wrong config file). Look for other installations of Apache / IIS. Or search your hdd for index.htm, index.html, index.php , it should be one of them.

  7. <a href="page/about">About</a>

     

    This is a relative path, assets requested by the browser will interpret this as relative to the current url. Since your rewrite makes it look like the file is one folder deep it's looking in the wrong place for the assets, you need to either use a full absolute URL or make them relative to root. In your case slapping a forward slash on the front of that should fix it.

  8. It sounds like you are triggering a redirect rather than a rewrite, which will cause the .htaccess to be parsed a second time. This time through the requrest is for page.php?slug=test-here, but when that hit's the rules you are replacing the slug value with the value of the page which is giving page.php?slug=page.php, not quite sure how that would be happening though as normally this would cause an infinite loop and crash. Perhaps it's hitting some kind of rewrite limit first. Either way, you should be able to stop that happening by adding another RewriteCond checking if the file requested actually exists.

     

    Options +FollowSymLinks
    
    RewriteEngine On
    RewriteCond %{REQUEST_URI} !\.(exe|jpg|jpeg|png)$
    RewriteCond %{REQUEST_URI} !-f
    RewriteCond %{REQUEST_URI} !-d
    RewriteRule ^([^/]*)$ page.php?slug=$1 [L]

     

  9. Firstly I'll assume your DNS settings are setup correctly to allow the subdomains to get forwarded to your VirtualHost, if that is the case then you do something along the lines of...

     

    RewriteEngine On

    RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.com

    RewriteRule ^(.*)$ /dir/%1/$1

  10. Step 1: make it work in the format /viewItem.php?id=$1

    (I'm assuming you've done this).

     

    Step 2: make a rewrite rule that matches your 'pretty' url and redirects it to the other one correctly

    Based on what you've posted, I'm going to assume that /viewItem.php?id=1 is accessible via viewItem1.htm, so you would do something like...

     

    RewriteEngine On

    RewriteRule ^/?viewItem[0-9]+\.htm$ /viewItem.php?id=$1

     

    If typing /viewItem1.htm in your address bar shows the correct page, Step 2 done.

     

    Step 3 : update links on your site to point at the new urls

    Update all the links on your site so that they read in the pretty format SEF format rather than the old query string.

     

    Step 4 : party

    I'm assuming you know how to do this.

×
×
  • 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.