- This topic is empty.
-
AuthorPosts
-
September 15, 2014 at 10:18 am #183104
Anonymous
InactiveI’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.
September 15, 2014 at 11:06 am #183112__
ParticipantJust 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]
September 15, 2014 at 1:40 pm #183156Anonymous
InactiveThis isn’t working. I tried this code but it didnt work either.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?id=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?id=$1
</IfModule>
<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.<IfModule mod_rewrite.c>
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
</IfModule>
<code></code>That also didn’t work. I don’t understand what htaccess is meant for.
September 15, 2014 at 1:57 pm #183161__
ParticipantThis 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.
September 16, 2014 at 3:21 pm #183309Anonymous
Inactivewhat 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-contentwhat you did
I added the following code to my .htaccess file.
RewriteEngine On
RewriteRule ^page/([^-]*)$ /page/index.php?id=$1 [L]
<code></code>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.
September 16, 2014 at 3:50 pm #183313__
ParticipantMuch better!
RewriteCond: bad argument line '^page/([^-]*)$'
That’s a
RewriteCond
error (not aRewriteRule
error). Are you sure you wroteRewriteRule
? 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?September 16, 2014 at 4:54 pm #183320Anonymous
InactiveI 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]September 16, 2014 at 6:27 pm #183323__
ParticipantI 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
)?September 16, 2014 at 7:56 pm #183324Anonymous
InactiveNot 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.
September 16, 2014 at 8:34 pm #183330__
ParticipantI 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 theid
of42
.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.
-
AuthorPosts
- The forum ‘Other’ is closed to new topics and replies.