Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other HTACCESS configure

  • This topic is empty.
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #183104
    Anonymous
    Inactive

    I’m trying to remove ?php=3 from my url and simply havewebsite.com/page/3 but my htaccess code isn’t working.

    RewriteEngine On
    RewriteRule /page/(.*)$ /page/index.php?id=$1
    <code></code>

    The URL is displayed like this
    http://website.com/page/?id=63

    I want to remove that “?id” The index.php file is located inside the page folder.

    #183112
    __
    Participant

    Just to clarify, your website needs URLs like this:
    http://example.com/page/index.php?id=63

    and you want to be able to use URLs like this instead:
    http://example.com/page/63

    Correct?

    The rule you have above would cause an infinite loop. You rewrite “anything” after page/ into “index.php” with a query string… however, “index.php” does qualify as “anything,” so it will trigger the rule again.

    Really, you’re look for one or more digits, aren’t you?

    RewriteEngine On
    RewriteRule page/(\d+)$ /page/index.php?id=$1 [L]
    
    #183156
    Anonymous
    Inactive

    This isn’t working. I tried this code but it didnt work either.

    &lt;IfModule mod_rewrite.c&gt;
    RewriteEngine On
    RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?id=$1
    RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?id=$1
    &lt;/IfModule&gt;
    <code></code>

    I have my htaccess file in the plublic_html directory, and my parked domain filesystem, where i want to change the url. Done i try linking the index.php file to its actual location?
    like so.

    &lt;IfModule mod_rewrite.c&gt;
    RewriteEngine On
    RewriteRule ^([a-zA-Z0-9_-]+)$ mywebsite.com/page/index.php?id=$1
    RewriteRule ^([a-zA-Z0-9_-]+)/$ mywebsite.com/page/index.php?id=$1
    &lt;/IfModule&gt;
    <code></code>

    That also didn’t work. I don’t understand what htaccess is meant for.

    #183161
    __
    Participant

    This isn’t working. I tried this code but it didnt work either.

    You need to be more specific. “It doesn’t work” is useless information —of course it doesn’t work; that’s why you’re asking for help. Instead, tell us:

    • what do you want to happen
    • what you did
    • what happened instead

    Especially for that middle part, be as descriptive and specific as possible. For example,

    the plublic_html directory

    Is that a typo?

    RewriteRule ^([a-zA-Z0-9_-]+)$ mywebsite.com/page/index.php?id=$1

    What are you trying to accomplish with this code? why did you make these changes?

    I have my htaccess file in the plublic_html directory, and my parked domain filesystem, where i want to change the url. Done i try linking the index.php file to its actual location?

    I don’t know what this means at all.

    Take your time when writing your comments, and proofread them before posting.

    If you are not fluent with English, see if you can find someone who can help translate. You might also tell us what your native language is, in case anyone here speaks it.

    #183309
    Anonymous
    Inactive

    what do you want to happen

    What i want to do is change my URL’s from
    http://website.com/page/?id=23 TO http://website.com/page/name-of-content

    what you did

    I added the following code to my .htaccess file.
    RewriteEngine On
    RewriteRule ^page/([^-]*)$ /page/index.php?id=$1 [L]
    &lt;code&gt;&lt;/code&gt;

    what happened instead

    Instead i got this error on the error log
    [Tue Sep 16 03:27:17 2014] [alert] [client XX.XXX.XXX.XXX]/home/domain/public_html/website.com/.htaccess: RewriteCond: bad argument line '^page/([^-]*)$', referer: http://website.com/

    and the 500 error page on the actual site.

    #183313
    __
    Participant

    Much better!

    RewriteCond: bad argument line '^page/([^-]*)$'

    That’s a RewriteCond error (not a RewriteRule error). Are you sure you wrote RewriteRule? or perhaps some other typo?

    But, more importantly, what do you want this rule to match? You’ve written “anything or nothing” ((.*)), “at least one letter, digit, and/or underscore” (([a-zA-Z0-9_-]+)), and now “anything (except a dash) or nothing” (([^-]*)).

    In your original post, it seemed you wanted to simply use the id number in the URL, without a query string: i.e., /page/42 instead of /page/index.php?id=42. If that’s correct, then you need to match only digits.

    Now, it seems you’ve changed your plan (you’re using page names instead of IDs?). So, what’s it to be? And do your scripts still need the ?id=nn form?

    #183320
    Anonymous
    Inactive

    I want to use page names instead of ID’s.

    On my htaccess file these are the only two lines of code in it. It’s RewriteRule.

    `
    RewriteEngine On
    RewriteRule ^movie/([^-]*)$ /movie/index.php?id=$1 [L]

    #183323
    __
    Participant

    I want to use page names instead of ID’s.

    And do your scripts know how to do this? or do you need to “translate” the page name into a id (or perhaps include one, like /page/my-page-title-42)?

    #183324
    Anonymous
    Inactive

    Not exactly. I have followed many tutorials and I still get the 500 error. I contact my webhost and they said it was a syntax error. But i seriously dont think thats what the issue is.

    #183330
    __
    Participant

    I don’t think you are understanding my question.

    When you visit /page/index.php?id=42, your scripts (your website scripts, i.e., index.php) knows what to display because it can look up which page has the id of 42.

    For example, if you use this rule

    RewriteRule page/(\d+)$ /page/index.php?id=$1
    

    …and visit /page/42, the only reason your website might know what to do is because the rule rewrites /page/42 into /page/index.php?id=42, and that is what the website “sees.”

    If your website needs that id number, you need to figure out a way to provide it. If you can’t, then no amount of rewriting will help.

    So, does your website know what to do if you give it a page title instead of an id?

    they said it was a syntax error. But i seriously dont think thats what the issue is.

    If you’re getting a 500 error, yes, it is most likely a syntax error.
    Undo the changes you made and see if the error goes away.

    I have followed many tutorials…

    Tutorials for what? Don’t try following directions for something without first understanding what it is you need to do. They might be directions for the wrong thing.

Viewing 10 posts - 1 through 10 (of 10 total)
  • The forum ‘Other’ is closed to new topics and replies.