473,385 Members | 1,645 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

.htaccess file is not working

160 100+
Hi to all
I m looking for some help. i want to do url rewritting. i write code e.g
Expand|Select|Wrap|Line Numbers
  1. Options +FollowSymLinks
  2. RewriteEngine on
  3. RewriteRule index/show/(.*)/cat/(.*)/ index.php?show=$1&cat=$2
  4. RewriteRule index/show/(.*)/cat/(.*) index.php?show=$1&cat=$2
  5.  
1)On local host its give an error "Internal Server Error". same error occurred even when i wrote just first two lines of above code.

2)On live site it not give any error but its not working at all. In fact there is no effect of writing above code.

is there any problem in php settings. Please send me some solution. I tried hard but did't find any solution
Feb 6 '10 #1

✓ answered by Atli

That's odd. The error messages should be in the log. Could be that XAMPP does something differently than a typical Apache installation.

Anyhow. Are you sure mod_rewrite is installed on the server, and that it is active?

Try wrapping the RewriteRule stuff in IfModule tags.
Expand|Select|Wrap|Line Numbers
  1. <IfModule mod_rewrite.c>
  2.     RewriteEngine On
  3.     RewriteRule index/show/(.*)/cat/(.*)/? index.php?show=$1&cat=$2
  4. </IfModule>
This will make sure the modules is active before trying to use it. If the module is not active, your rewrite rules will simply be ignored. Your site will work, but the rewrite rules will not.

P.S.
I combined your two rules into one in that example. If you trail any character in a regular expression with a question-mark it becomes optional.

12 4336
Atli
5,058 Expert 4TB
Hey.

Have you checked the error log to see what is going on?
By default, the file is located at:
"C:\Program Files\Apache Software Foundation\Apache2.2\logs\error.log". (On Windows, that is)

On Linux they can be in different places. I'd start by looking at the /var/log directory.
Feb 6 '10 #2
waqasahmed996
160 100+
Thanks Atli for your kind reply

i opened error.log but i dont know how to check from error.log that what is going on
Feb 6 '10 #3
Atli
5,058 Expert 4TB
Check the latest entries. When you get an internal server error the actual error is written into those logs.

You can post them here (not all of them, just those that happened at the time your internal server error happened) and we can help you figure them out.
Feb 6 '10 #4
waqasahmed996
160 100+
Thanks Atil for your reply. Atil i dont think so that any thing happened in error log due to that error. i am facing this error rite now but last few lines of error log are

Expand|Select|Wrap|Line Numbers
  1. [Wed Dec 10 09:45:25 2008] [error] [client 127.0.0.1] File does not exist: C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/favicon.ico
  2. [Wed Dec 10 09:49:45 2008] [notice] Parent: Received shutdown signal -- Shutting down the server.
  3. [Wed Dec 10 09:49:45 2008] [notice] Child 3912: Exit event signaled. Child process is ending.
  4. [Wed Dec 10 09:49:46 2008] [notice] Child 3912: Released the start mutex
  5. [Wed Dec 10 09:49:49 2008] [notice] Child 3912: All worker threads have exited.
  6. [Wed Dec 10 09:49:49 2008] [notice] Child 3912: Child process is exiting
  7. [Wed Dec 10 09:49:49 2008] [notice] Parent: Child process exited successfully.
  8.  
  9.  
i also want to mention that i am using wamp and this file exist in
C:\wamp\bin\apache\Apache2.2.11\logs
Feb 6 '10 #5
waqasahmed996
160 100+
Any other reason for that problem?
Feb 7 '10 #6
Atli
5,058 Expert 4TB
That's odd. The error messages should be in the log. Could be that XAMPP does something differently than a typical Apache installation.

Anyhow. Are you sure mod_rewrite is installed on the server, and that it is active?

Try wrapping the RewriteRule stuff in IfModule tags.
Expand|Select|Wrap|Line Numbers
  1. <IfModule mod_rewrite.c>
  2.     RewriteEngine On
  3.     RewriteRule index/show/(.*)/cat/(.*)/? index.php?show=$1&cat=$2
  4. </IfModule>
This will make sure the modules is active before trying to use it. If the module is not active, your rewrite rules will simply be ignored. Your site will work, but the rewrite rules will not.

P.S.
I combined your two rules into one in that example. If you trail any character in a regular expression with a question-mark it becomes optional.
Feb 7 '10 #7
waqasahmed996
160 100+
Thanks Atli,
you are right mod rewrite is not installed. i came to know this by using your code in which you use if condition
please tell me what is next step now. how i ll install it
Feb 7 '10 #8
Atli
5,058 Expert 4TB
I have never really used XAMPP myself so I wouldn't know, but Google seems to have a lot of info on the subject.
Feb 7 '10 #9
waqasahmed996
160 100+
Thanks Atil. You really help me
Feb 7 '10 #10
Atli
5,058 Expert 4TB
Your welcome. Glad I could help :)

One last thing I should point out though.

Your RewriteRule. It is meant to allow you to use this URL:
- index/show/zzz/cat/yyy/
instead of this URL:
- index.php?show=zzz1&cat=yyy

I should point out that search engines would most likely have an easier time understanding the original one, with the query-string. There, they can match up the values with their respective keys, whereas in your new version they can't.

In fact, you may well be better of leaving it unaltered.
If not, I still suggest you change the structure of the new URL. If you explain what the values - show and cat - mean and I can make a suggestion.

See these fore more details:And you can probably find a lot more of those via Google.
Feb 7 '10 #11
waqasahmed996
160 100+
excellent point
i am doing this to make site SEO friendly
and i also read and heard from many people to use urls like
index/show/zzz/cat/yyy/
to make them SEO friendly
Atli what about if we use urls like
index-show-zzz1-cat-yyy.htm
by using url rewriting instead index/show/zzz/cat/yyy/
will it be helpful to make site SEO friendly??
Feb 7 '10 #12
Atli
5,058 Expert 4TB
No, not really. Leaving it like "index.php?show=zzz&cat=yyy" would most likely be more SEO friendly. - It is easier for a computer to understand that zzz is the value of show, and that yyy is the value of cat when you use this basic format. - When you set them up side-by-side in a directory hierarchy - or even worse; as a single file name -, that becomes harder to determine. The key and the value become as two separate, equal-value values, when in fact they should be a key-value pair.

It is best to just set the URL up in a way that would be most easily understood by a human. In your case, assuming show represents an action (e.g. "list" or "details") that is to be taken on a given category, something like this may be a good idea:
  • example.com/categories/zzz.php?category=yyy
That might turn into something like:
  • example.com/categories/list.php?category=name-of-category
  • example.com/categories/details.php?category=name-of-category
  • example.com/categories/details.php?category-id=1234
There, from the point of view of an outsider, each of your show parameters is a different PHP file, inside a "categories" directory, which takes a cat (or category) as a parameter. Pretty easy to understand both by a human visitor and by a bot.

P.S.
You should note that most of the SEO tricks that you see floating around are mostly bogus, or at least have very limited effectiveness.
A few common SEO tricks that people waste way to much time on:
  • Pretty-URLs. (mod_rewrite)
    In some cases this may have it's uses, but for the most part, use this to improve things for your human visitors, not the bots.
  • Meta description/keywords.
    This was exploited so much in the past that it is hardly worth using today. You should of course include the description (Google might display it with the link in the search results), and adding a few keywords is fine, but don't think either will improve your SEO rating.
  • Keyword spamming.
    This was also exploited. People crammed keywords all over the page to score high for them in the search results. - Today Google is more likely to penalize you for this. - You should of course include your keywords in your text, but write it for a human not for a bot.
  • Bold/strong text
    Again, exploited in the past. Bold words are traditionally more important than others, and as such, weigh more on the search results. But overusing it will just hurt you. - Use it as it was intended: to emphasize words to human readers, not to bots.
  • Link-exchange
    This *can* be helpful if used responsibly, but people are rarely responsible. - It is far more effective to write good content and "naturally" link to other pages with good content. They, in turn, may become aware of your site and link back to your content.
  • ... spamming
    An obvious way to get black-listed; banned from even appearing in search results at all. - We sometimes see it on forums like these. People signing up solely to post links to their new site, promoting their new business site. - We promptly delete stuff like that and submit it to be black-listed. - Most forum systems do.
Don't get me wrong, some of these may have limited usefulness, but compared to good content, this is close to irrelevant. - The best way to get your site noticed is to have good content; content that people will want to read and link to. A single link to your content is worth more than all of these SEO tricks combined. - Spend more time creating good content; less time on SEO. Focus on your human visitors, not the bots.
Feb 8 '10 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: yawnmoth | last post by:
i'm trying to write a php script that will password protect some random directory by creating a .htaccess file, and a password file to accompany the .htaccess file, and it isn't working... ...
4
by: Ivo | last post by:
Greetings newsgroup, I am moving some php scripts to a new host. While getting to know the server, I ran into a strange problem. If I add a .htaccess file, or more specifically: a .htaccess with...
7
by: Nel | last post by:
Just looking for some general advice on modifying the URL for php. I am using .htaccess to allow a web site to translate example.html to index.php?content=example (below) ErrorDocument 404...
7
by: John | last post by:
Hello. I want to get this blasted .htaccess file sorted out, so I can have sessions without register_globals being on. I have looked everywhere for info on this and I mean everywhere...
0
by: Jack Hambabo | last post by:
Hi, I'm searching for a php script that can find out whether the current user (I know _SERVER will give me the name for non-cgi php) has the right to view a specific file. My dream is that I...
0
by: asherwolf | last post by:
Hi, I'm trying to do something I think is pretty neat, but I've just about pulled my hair out by the behavior of my server. I'm hosting on GoDaddy, using a subdomain (www.mywebpage.com maps to...
8
by: Thiago Macedo | last post by:
Hi folks, I have the Apacha server (2.2.8) with PHP installed as CGI Binary. This, as i'm discovering, means that I can't change php configurations through .htaccess. Is my searches right or...
4
by: adnanjunk | last post by:
Hi, Having a little issue with .htaccess not working on windows server. I have clean url's setup using the htaccess file, working fine on linux server. I have researched for a while and found...
0
by: AndyPSV | last post by:
Hello, I've got .htaccess file: RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule (.*) index.php It works properly on mine and...
2
Markus
by: Markus | last post by:
Why is it not working? I joke. Here's the info: In the folder C:\host\www\test, I have an .htaccess file. Inside that .htaccess file is the following: RewriteEngine On RewriteRule...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.